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.

Author pitrou
Recipients pitrou, rhettinger
Date 2009-01-25.16:16:10
SpamBayes Score 1.4795585e-05
Marked as misclassified No
Message-id <1232900172.29.0.659028766072.issue5057@psf.upfronthosting.co.za>
In-reply-to
Content
The peephole optimizer can optimize indexed access to an unicode
constant which does not give the same result in UCS-2 and UCS-4 builds.
As a result, the pyc file is not portable across those builds.

This is something I witnessed when recompiling in UCS-2 rather than
UCS-4 mode, and having a strange failure in test_multibytecodec. Erasing
test_multibytecodec.pyc suppressed the failure.

Here is a small demonstration of the problem:

>>> def f():
...  return '\U00012345'[0]
... 
>>> import dis
>>> dis.dis(f)
  2           0 LOAD_CONST               3 ('\ud808') 
              3 RETURN_VALUE         


For reference, here is the error I had in test_multibytecodec:

======================================================================
FAIL: test_gb18030 (test.test_multibytecodec.Test_StreamWriter)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/antoine/py3k/__svn__/Lib/test/test_multibytecodec.py",
line 185, in test_gb18030
    self.assertEqual(s.getvalue(), b'123\x907\x959')
AssertionError: b'123\x907\x959\x907\x959' != b'123\x907\x959'

----------------------------------------------------------------------
History
Date User Action Args
2009-01-25 16:16:12pitrousetrecipients: + pitrou, rhettinger
2009-01-25 16:16:12pitrousetmessageid: <1232900172.29.0.659028766072.issue5057@psf.upfronthosting.co.za>
2009-01-25 16:16:11pitroulinkissue5057 messages
2009-01-25 16:16:10pitroucreate