Eryk Sun added the comment:

It duplicates translated characters as well. For example:

    >>> table = str.maketrans('mnopqrb', 'rqponm\u0100', 'a')
    >>> 'aaaaaamnopqrb'.translate(table)
    'rqponmrqponmĀ'

3.4 returns the correct result:

    >>> table = str.maketrans('mnopqrb', 'rqponm\u0100', 'a')
    >>> 'aaaaaamnopqrb'.translate(table)
    'rqponmĀ'

The problem is the new fast path for one-to-one ASCII mapping 
(unicode_fast_translate in Objects/unicodeobject.c) doesn't have a way to 
return the current input position in order to resume processing the 
translation. _PyUnicode_TranslateCharmap assumes it's the same as the current 
writer position, which is wrong when input characters have been deleted.

----------
nosy: +eryksun
title: str.translate() unexpectedly duplicates untranslated characters -> 
str.translate() unexpectedly duplicates characters

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26464>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to