<br>While merging the trunk changes into the p3yk branch, I discovered what I think is a bug in the stream codecs. It's easily reproduced in the trunk: in Lib/codecs.py, make the 'Codec' class new-style. Then, suddenly, test_codecs will crash with an exception like this:
<br><br>======================================================================<br>ERROR: test_basics (test.test_codecs.BasicUnicodeTest)<br>----------------------------------------------------------------------<br>Traceback (most recent call last):
<br> File "/home/thomas/python/python/trunk/Lib/test/test_codecs.py", line 1089, in test_basics<br> writer = codecs.getwriter(encoding)(q)<br> File "/home/thomas/python/python/trunk/Lib/codecs.py", line 296, in __init__
<br> self.stream = stream<br>TypeError: readonly attribute<br><br>Looking at the class, it's hard to tell how it's suddenly a read-only attribute, until you figure out which codec it breaks with: big5. Which is defined in
encodings.big5, as a subclass of codecs.Codec, _multibytecodec.MultibyteStreamWriter and codecs.StreamWriter. And _multibytecodec.MultibyteStreamWriter is a new-style class (as it's defined in C) with a read-only 'stream' attribute. The conflicting attribute is silently masked by Python, since classic classes ignore two-thirds of the descriptor protocol (setting and deleting), but it jumps right out when all classes become new-style.
<br clear="all"><br>I'm not sure whether this attribute conflict is on purpose or not, but since it will break in the future, I suggest it gets fixed. It *looks* like renaming the _MultibyteStreamWriter attribute is the easiest solution, but I don't know which API has precedence. (One of the two was added fairly recently, at least, since it didn't break in the p3yk branch until I merged in the last few months' worth of changes :)
<br><br>-- <br>Thomas Wouters <<a href="mailto:thomas@python.org">thomas@python.org</a>><br><br>Hi! I'm a .signature virus! copy me into your .signature file to help me spread!