[obs-commits] [openSUSE/osc2] d093c2: - test.util.test_io: test corner case in Temporary...
Branch: refs/heads/master Home: https://github.com/openSUSE/osc2 Commit: d093c2b43ba13774ade4b1fc81874b119edce767 https://github.com/openSUSE/osc2/commit/d093c2b43ba13774ade4b1fc81874b119edc... Author: Marcus Huewe <suse-tux@gmx.de> Date: 2015-01-03 (Sat, 03 Jan 2015) Changed paths: M test/util/test_io.py Log Message: ----------- - test.util.test_io: test corner case in TemporaryDirectory.__del__ Avoid an unraised exception: Exception AttributeError: "'NoneType' object has no attribute 'path'" in <bound method TemporaryDirectory.__del__ of <osc2.util.io.TemporaryDirectory object at 0x7f8abc8d7910>> ignored This exception was "raised" in the TemporaryDirectory.__del__ method, if the "osc2.util.io" was already "unloaded" (the __del__ method calls the _cleanup method, which tried to call the os.path.isdir function). What happened is the following: If the "osc2.util.io" module is passed to _PyModule_Clear (Objects/moduleobject.c), almost all entries in the module dict are set to None. That is, the entry for the key "os" points to None. Now, suppose that there is still a TemporaryDirectory instance around, whose __del__ method is eventually called. During this call, "os" resolves to None and therefore the subsequent lookup for the name "path" leads to the AttributeError. Instead of raising this exception, it is just printed to stderr, because it occurred in a __del__ method (see slot_tp_del (Objects/typeobject.c) and PyErr_WriteUnraisable (Python/errors.c)). Commit: 9448026bcf2cfbf87659035556e8bcc9f61babcb https://github.com/openSUSE/osc2/commit/9448026bcf2cfbf87659035556e8bcc9f61b... Author: Marcus Huewe <suse-tux@gmx.de> Date: 2015-01-03 (Sat, 03 Jan 2015) Changed paths: M osc2/util/io.py Log Message: ----------- - util.io.TemporaryDirectory: fixed corner case in __del__ Compare: https://github.com/openSUSE/osc2/compare/c9f8491f6183...9448026bcf2c
participants (1)
-
Marcus Huewe