homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_codecs fails when ran after test_zipimport and test_mailbox.
Type: behavior Stage: patch review
Components: Tests Versions: Python 3.1, Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: alexandre.vassalotti, amaury.forgeotdarc, pitrou, r.david.murray
Priority: normal Keywords: patch

Created on 2009年07月23日 03:04 by alexandre.vassalotti, last changed 2022年04月11日 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
testcase1.py alexandre.vassalotti, 2009年07月23日 03:12 This test case does _not_ trigger the bug.
testcase2.py alexandre.vassalotti, 2009年07月23日 03:13 This test case triggers the bug.
testcase3.py alexandre.vassalotti, 2009年07月23日 03:17 Pruned version of testcase1.py; this triggers the bug.
testcase4.py alexandre.vassalotti, 2009年07月23日 03:17 Pruned version of testcase2.py; this triggers the bug.
modcleanup.patch pitrou, 2009年11月13日 01:57
Messages (6)
msg90837 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2009年07月23日 03:04
For some yet unknown reason, test_codecs fails when it is run after
test_zipimport and subsequently test_mailbox:
./python Lib/test/regrtest.py -w test_zipimport test_mailbox test_codecs
[SNIP]
======================================================================
ERROR: test_basics (test.test_codecs.BasicUnicodeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
 File "/home/alex/src/python.org/py3k/Lib/test/test_codecs.py", line
1360, in test_basics
 encodedresult += encoder.encode(c)
 File "/home/alex/src/python.org/py3k/Lib/encodings/ascii.py", line 22,
in encode
 return codecs.ascii_encode(input, self.errors)[0]
AttributeError: 'NoneType' object has no attribute 'ascii_encode'
======================================================================
ERROR: test_decoder_state (test.test_codecs.BasicUnicodeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
 File "/home/alex/src/python.org/py3k/Lib/test/test_codecs.py", line
1445, in test_decoder_state
 self.check_state_handling_decode(encoding, u, u.encode(encoding))
 File "/home/alex/src/python.org/py3k/Lib/test/test_codecs.py", line
30, in check_state_handling_decode
 part1 = d.decode(s[:i])
 File "/home/alex/src/python.org/py3k/Lib/encodings/ascii.py", line 26,
in decode
 return codecs.ascii_decode(input, self.errors)[0]
AttributeError: 'NoneType' object has no attribute 'ascii_decode'
----------------------------------------------------------------------
Ran 121 tests in 0.204s
FAILED (errors=2)
test test_codecs failed -- errors occurred; run in verbose mode for details
msg90844 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009年07月23日 13:35
When the zipimport test is run, encodings.ascii is imported. Then it is
removed from sys.modules by the test cleanup. When the mailbox test is
run, it is reimported. However, when the codecs test tries to use it,
the encodings.ascii module has been finalized (as if during interpreter
shutdown) by having all its globals set to None. Thus the test failure.
I haven't figured out why this is happening yet, but it seems likely
that the issue is either with zipimport or with the zipimport test
cleanup. I'm guessing that anything that triggers encodings.ascii to be
loaded before test_codecs tries to use it will trigger the bug, but I
haven't tested that theory yet.
msg90846 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009年07月23日 13:59
A simple solution could be to import encodings.ascii in regrtest.py,
before it saves the list of modules.
Or, since codecs are stored in a global cache dictionary that cannot be
cleared (interp->codec_search_cache), avoid unloading modules from the
encodings package.
msg95171 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009年11月13日 01:56
Here is a patch.
msg95172 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2009年11月13日 02:04
The patch looks good to me.
msg95185 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009年11月13日 16:32
Thanks. The patch is now committed in py3k and 3.1.
History
Date User Action Args
2022年04月11日 14:56:51adminsetgithub: 50800
2009年11月13日 16:32:18pitrousetstatus: open -> closed
resolution: accepted -> fixed
messages: + msg95185
2009年11月13日 02:04:48alexandre.vassalottisetresolution: accepted
messages: + msg95172
2009年11月13日 01:57:07pitrousetfiles: + modcleanup.patch
keywords: + patch
2009年11月13日 01:56:31pitrousetnosy: + pitrou

messages: + msg95171
stage: needs patch -> patch review
2009年07月23日 13:59:26amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg90846
2009年07月23日 13:35:54r.david.murraysetnosy: + r.david.murray

messages: + msg90844
versions: + Python 3.1
2009年07月23日 03:17:45alexandre.vassalottisetfiles: + testcase4.py
2009年07月23日 03:17:06alexandre.vassalottisetfiles: + testcase3.py
2009年07月23日 03:13:27alexandre.vassalottisetfiles: + testcase2.py
2009年07月23日 03:12:18alexandre.vassalottisetfiles: + testcase1.py
2009年07月23日 03:04:32alexandre.vassalotticreate

AltStyle によって変換されたページ (->オリジナル) /