<div dir="ltr"><p class="gmail-p1"><span style="color:rgb(0,0,0)">Hi,</span><br><span style="color:rgb(0,0,0)">Thanks again for adding the</span><span class="gmail-Apple-converted-space" style="color:rgb(0,0,0)"> </span><span class="gmail-s1" style="color:rgb(0,0,0)">_close</span><span class="gmail-Apple-converted-space" style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,0,0)">caching change.</span><br><font color="#000000"><span style="caret-color: rgb(0, 0, 0);"><br></span></font><span style="color:rgb(0,0,0)">It seems the inserted line is indented with a tab, while the rest of the file uses spaces. Right now it looks like this:</span><br><span style="color:rgb(0,0,0)">class Magic(object):</span><br><span style="color:rgb(0,0,0)"> def __init__(self, ms):</span><br><span style="color:rgb(0,0,0)"> self._magic_t = ms</span><br><span style="color:rgb(0,0,0)"> self._close = _close</span><br><span style="color:rgb(0,0,0)">Note the tab before</span><span class="gmail-Apple-converted-space" style="color:rgb(0,0,0)"> </span><span class="gmail-s1" style="color:rgb(0,0,0)">self._close</span><span style="color:rgb(0,0,0)">, which (</span><span style="color:rgb(0,0,0);font-family:Monaco,Menlo,Consolas,"Courier New",monospace;font-size:12px;background-color:rgb(248,248,248)">python3 magic.py</span><span style="color:rgb(0,0,0)">) leads to:</span><br><span style="color:rgb(0,0,0)"> TabError: inconsistent use of tabs and spaces in indentation</span><br></p><p class="gmail-p1"><font color="#000000"><span style="caret-color: rgb(0, 0, 0);"><br></span></font><span style="color:rgb(0,0,0)">Could you replace the tab with 4 spaces to match the surrounding indentation?</span><font color="#000000"><span style="caret-color: rgb(0, 0, 0);"><br></span></font><span style="color:rgb(0,0,0)">Thanks for taking a look into it again.</span></p><p class="gmail-p1"><font color="#000000"><span style="caret-color: rgb(0, 0, 0);"><br></span></font><span style="color:rgb(0,0,0)">Best regards,</span><font color="#000000"><span style="caret-color: rgb(0, 0, 0);"><br></span></font><span style="color:rgb(0,0,0)">Vincent</span><font color="#000000"><span style="caret-color: rgb(0, 0, 0);"><br></span></font></p></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Mon, Feb 16, 2026 at 3:25 PM Christos Zoulas <<a href="mailto:christos@zoulas.com">christos@zoulas.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="line-break:after-white-space">Done!<div><br></div><div>christos<br id="m_-57436999019874095lineBreakAtBeginningOfMessage"><div><br><blockquote type="cite"><div>On Feb 16, 2026, at 3:26 AM, Vincent Mihalkovic <<a href="mailto:vmihalko@redhat.com" target="_blank">vmihalko@redhat.com</a>> wrote:</div><br><div><p><u></u><u></u></p><p><u></u>Hi,<u></u></p><p><u></u>Thank you for accepting the patch — I appreciate it.<u></u></p><p><u></u>I noticed that the merged change keeps the conditional guard in<u></u><u></u> <u></u><code>close()</code><u></u>, but does not include:<u></u><br><u></u> self._close = _close<u></u><br><u></u>That line was intended to cache the<u></u><u></u> <u></u><code>magic_close</code><u></u> <u></u><u></u>function on the instance. The current<u></u><u></u> <u></u><code>if _close:</code><u></u> <u></u><u></u>avoids the traceback, but it still relies on the module-global<u></u><u></u> <u></u><code>_close</code><u></u>, which may already be cleared during interpreter shutdown. Storing the function on the instance ensures it remains available when<u></u><u></u> <u></u><code>__del__</code><u></u> <u></u><u></u>runs.<u></u></p><p><u></u>Would you consider also adding the<u></u><u></u> <u></u><code>self._close = _close</code><u></u> <u></u><u></u>line?<u></u></p><p><u></u>Best regards,<u></u><br><u></u>Vincent<u></u><br></p><div><br></div><u></u><br><p><u></u><u></u></p><p><u></u>On Tue, Feb 10, 2026 at 1:52 PM Vincent Mihalkovic <<a href="mailto:vmihalko@redhat.com" target="_blank">vmihalko@redhat.com</a>> wrote:<br><u></u></p><u></u><blockquote class="gmail_quote"><p><u></u><u></u></p><p><u></u>Hi,<u></u><br><font><u></u><br><u></u></font><u></u>I am seeing a<u></u><u></u> <u></u><u></u>TypeError<u></u><u></u> <u></u><u></u>at Python interpreter shutdown when using the Python bindings shipped with file (<u></u><u></u>python/magic.py<u></u><u></u>).<u></u><br><font><u></u><br><u></u></font><u></u>MagicDetect.__del__()<u></u><u></u><u></u> <u></u>calls<u></u> <u></u><u></u><u></u>Magic.close()<u></u><u></u><u></u> <u></u>(see<u></u><u></u> <u></u><u></u><a href="https://github.com/file/file/blob/master/python/magic.py#L300-L310" target="_blank">https://github.com/file/file/blob/master/python/magic.py#L300-L310</a>), <u></u><u></u>which in turn calls the module-global<u></u><u></u> <u></u><u></u>_close<u></u><u></u> <u></u><u></u>in<u></u><u></u> <u></u><u></u>Magic.close()<u></u><u></u> <u></u><u></u>(see <u></u><u></u><a href="https://github.com/file/file/blob/master/python/magic.py#L130-L136" target="_blank">https://github.com/file/file/blob/master/python/magic.py#L130-L136</a>).<u></u></p><p><u></u>During interpreter shutdown, module globals may already be cleared, so<u></u><u></u> <u></u><u></u>_close<u></u><u></u> <u></u><u></u>can become<u></u><u></u> <u></u><u></u>None<u></u><u></u>, resulting in: <u></u><u></u>TypeError: ‘NoneType’ object is not callable<u></u><br><font><u></u><br><u></u></font><u></u>The attached patch avoids relying on the module-global<u></u><u></u> <u></u><u></u>_close<u></u><u></u> <u></u><u></u>during finalization by caching the<u></u><u></u> <u></u><u></u>magic_close<u></u><u></u> <u></u><u></u>function pointer on the<u></u><u></u> <u></u><u></u>Magic<u></u><u></u> <u></u><u></u>instance and using that in<u></u><u></u> <u></u><u></u>close()<u></u><u></u>. This prevents the shutdown exception without changing normal runtime behavior.<u></u><br><font><u></u><br><u></u></font><u></u>Related downstream report:<u></u><br><u></u><a href="https://bugzilla.redhat.com/show_bug.cgi?id=2419719" target="_blank">https://bugzilla.redhat.com/show_bug.cgi?id=2419719</a><u></u><br><font><u></u><br><u></u></font><u></u>Best regards,<u></u><br><u></u>Vincent<u></u><br></p><div><br></div><u></u>
<u></u></blockquote><div><br></div><u></u>
-- <br>File mailing list<br><a href="mailto:File@astron.com" target="_blank">File@astron.com</a><br><a href="https://mailman.astron.com/mailman/listinfo/file" target="_blank">https://mailman.astron.com/mailman/listinfo/file</a><br><span id="m_-57436999019874095cid:E02B0617-2946-4C72-B42F-468837693281"><sanitizer.log></span><u></u><u></u><u></u></div></blockquote></div><br></div></div></blockquote></div>