[issue7027] test_io.py: codecs.IncrementalDecoder is sometimes None

STINNER Victor report at bugs.python.org
Tue Apr 27 19:19:31 CEST 2010


STINNER Victor <victor.stinner at haypocalc.com> added the comment:

This issue is specific to Python 2.6. It can be reproduced with:

./python -E -tt ./Lib/test/regrtest.py -l -w test_pep263 test_operator test_asynchat test_zipimport_support test_pydoc test_code test_dis test_quopri test_doctest test_class test_sax test_fileio test_asyncore test_mailbox test_abstract_numbers test_uuid test_io test_enumerate test_property test_codecs

Or with this little test case:
----
import codecs, _codecs, sys, encodings

encoding = "cp1252"

codec = _codecs.lookup(encoding)

modname = 'encodings.%s' % encoding
__import__(modname)
del sys.modules[modname]
delattr(encodings, encoding)

encoder = codecs.getincrementalencoder(encoding)()
encoder.encode("", True)
----

module_dealloc() was modified in python trunk: the dictionary is only cleared if the reference counter is equal to 1.

/* If we are the only ones holding a reference, we can clear the dictionary. */
if (Py_REFCNT(m->md_dict) == 1) _PyModule_Clear((PyObject *)m);

----------
versions:  -Python 2.7, Python 3.1, Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7027>
_______________________________________


More information about the Python-bugs-list mailing list