Issue 23803: str.partition() is broken in 3.4 (original) (raw)

Tests added in b923eeaf8162 exposed a bug in str.partition() and str.rpartition() in 3.4 on big-endian platforms. It should exist in 3.3 too. It likely was fixed in 3.5 in .

http://buildbot.python.org/all/builders/PPC64%20PowerLinux%203.4/builds/913/steps/test/logs/stdio

FAIL: test_partition (test.test_unicode.UnicodeTest)

Traceback (most recent call last): File "/home/shager/cpython-buildarea/3.4.edelsohn-powerlinux-ppc64/build/Lib/test/test_unicode.py", line 383, in test_partition left + right, 'partition', delim) File "/home/shager/cpython-buildarea/3.4.edelsohn-powerlinux-ppc64/build/Lib/test/string_tests.py", line 63, in checkequal realresult AssertionError: Tuples differ: ('bbbbbbbbbaaaaaaaaa', '', '') != ('', '𐌂', '\x00\x00b\x00\x00\x00b\x00\x00\x00b\x00\x00\x00b\x00\x00')

First differing element 0: bbbbbbbbbaaaaaaaaa

====================================================================== FAIL: test_rpartition (test.test_unicode.UnicodeTest)

Traceback (most recent call last): File "/home/shager/cpython-buildarea/3.4.edelsohn-powerlinux-ppc64/build/Lib/test/test_unicode.py", line 399, in test_rpartition left + right, 'rpartition', delim) File "/home/shager/cpython-buildarea/3.4.edelsohn-powerlinux-ppc64/build/Lib/test/string_tests.py", line 63, in checkequal realresult AssertionError: Tuples differ: ('', '', 'bbbbbbbbbaaaaaaaaa') != ('\x00\x00\x00b\x00\x00\x00b\x00\x00\x00b\x00\x00\x00b\x00', '𐌂', '')

First differing element 0:

bbbb


'bbbbbbbbbaaaaaaaaa'.partition('\U00010302') returns ('', '𐌂', '\x00\x00b\x00\x00\x00b\x00\x00\x00b\x00\x00\x00b\x00\x00') 'bbbbbbbbbaaaaaaaaa'.rpartition('\U00010302') returns ('\x00\x00\x00b\x00\x00\x00b\x00\x00\x00b\x00\x00\x00b\x00', '𐌂', '')

The bug can be reproduced on little-endian platform.

'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.partition('Ā') ('A', 'Ā', 'B\x00C\x00D\x00E\x00F\x00G\x00H\x00I\x00J\x00K\x00L\x00M\x00') 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.rpartition('Ā') ('A\x00B\x00C\x00D\x00E\x00F\x00G\x00H\x00I\x00J\x00K\x00L\x00M', 'Ā', '')