Description of problem: TypeError on exit from python process that used magic. Version-Release number of selected component (if applicable): python3-file-magic-5.46-8.fc44.noarch python3-file-magic-5.46-3.fc42.noarch I'm seeing a 100% reproducible TypeError when exiting a Python process that has used magic: Exception ignored while calling deallocator <function MagicDetect.__del__ at 0x7f44719aef00>: Traceback (most recent call last): File "/usr/lib/python3.14/site-packages/magic.py", line 308, in __del__ File "/usr/lib/python3.14/site-packages/magic.py", line 135, in close TypeError: 'NoneType' object is not callable This is happening via: 74 _close = _libraries['magic'].magic_close ... 131 def close(self): 132 """ 133 Closes the magic database and deallocates any resources used. 134 """ 135 _close(self._magic_t) ... 285 class MagicDetect(object): ... 306 def __del__(self): 307 if self.mime_magic is not None: 308 self.mime_magic.close() 309 if self.none_magic is not None: 310 self.none_magic.close() It goes away if I patch magic.py: --- magic.py.orig 2025-12-06 15:18:29.841776375 -0500 +++ magic.py 2025-12-06 15:18:37.777000000 -0500 @@ -132,7 +132,8 @@ class Magic(object): """ Closes the magic database and deallocates any resources used. """ - _close(self._magic_t) + if _close: + _close(self._magic_t) @staticmethod def __tostr(s): But this seems like it's just working around the problem. Affects rawhide and f42 but does not appear in python3-file-magic-5.39-16.el9.noarch in c9s/rhel9. Haven't tested other Fedora releases yet. Reproducible: Always Steps to Reproduce: It's easiest to reproduce in the Python shell: # python3 Python 3.14.0 (main, Oct 17 2025, 00:00:00) [GCC 15.2.1 20250924 (Red Hat 15.2.1-2)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import magic >>> magic.detect_from_filename("/etc/os-release") FileMagic(mime_type='inode/symlink', encoding='binary', name='symbolic link to ../usr/lib/os-release') >>> Exception ignored while calling deallocator <function MagicDetect.__del__ at 0x7f4b3fb9af00>: Traceback (most recent call last): File "/usr/lib/python3.14/site-packages/magic.py", line 308, in __del__ File "/usr/lib/python3.14/site-packages/magic.py", line 135, in close TypeError: 'NoneType' object is not callable Actual Results: Exception ignored while calling deallocator <function MagicDetect.__del__ at 0x7f4b3fb9af00>: Traceback (most recent call last): File "/usr/lib/python3.14/site-packages/magic.py", line 308, in __del__ File "/usr/lib/python3.14/site-packages/magic.py", line 135, in close TypeError: 'NoneType' object is not callable Expected Results: No exception output. Additional Information: I see this with some scripts using "#!/usr/bin/python3" but not others - it's not clear why yet. A trivial: # cat /tmp/magictest.py #!/usr/bin/python3 import magic print(magic.detect_from_filename('/etc/os-release')) Does not show the error: # /tmp/magictest.py FileMagic(mime_type='inode/symlink', encoding='binary', name='symbolic link to ../usr/lib/os-release') # But a script that uses packages that indirectly import magic does: # /tmp/diffest.py before-upgrade > /dev/null INFO - Discovering snapshot set mounts under '/run/snapm/mounts' INFO - Found snapshot set mount at '/run/snapm/mounts/before-upgrade' (mounted=True) INFO - Found 1 snapshot set mounts INFO - Gathering paths to scan from '/run/snapm/mounts/before-upgrade/etc' INFO - Gathering paths to scan from '/etc' Exception ignored in: <function MagicDetect.__del__ at 0x7f6db98ffa60> Traceback (most recent call last): File "/usr/lib/python3.13/site-packages/magic.py", line 308, in __del__ File "/usr/lib/python3.13/site-packages/magic.py", line 135, in close TypeError: 'NoneType' object is not callable
Forgot to add f43 is also affected (python3-file-magic-5.46-8.fc43.noarch).
Resolved via: https://src.fedoraproject.org/rpms/file/pull-request/39 Thank you for the report, I did a follow-up on your fix and upstreamed the change!
Awesome, thanks! I followed the dist-git PR. I'm out this afternoon but I will test when I can-patches LGTM!
FEDORA-2026-a740b8672f (file-5.47-1.fc45) has been submitted as an update to Fedora 45. https://bodhi.fedoraproject.org/updates/FEDORA-2026-a740b8672f
FEDORA-2026-a740b8672f (file-5.47-1.fc45) has been pushed to the Fedora 45 stable repository. If problem still persists, please make note of it in this bug report.