[issue36072] str.translate() behave differently for ASCII-only and other strings

Sergey Fedoseev report at bugs.python.org
Fri Feb 22 00:34:29 EST 2019


New submission from Sergey Fedoseev <fedoseev.sergey at gmail.com>:

In [186]: from itertools import cycle

In [187]: class ContainerLike:
     ...:     def __init__(self):
     ...:         self.chars = cycle('12')
     ...:     def __getitem__(self, key):
     ...:         return next(self.chars)
     ...: 

In [188]: 'aaaaaa'.translate(ContainerLike())
Out[188]: '111111'

In [189]: 'ыыыыыы'.translate(ContainerLike())
Out[189]: '121212

It seems that behavior was changed in https://github.com/python/cpython/commit/89a76abf20889551ec1ed64dee1a4161a435db5b. At least it should be documented.

----------
messages: 336279
nosy: sir-sigurd
priority: normal
severity: normal
status: open
title: str.translate() behave differently for ASCII-only and other strings

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36072>
_______________________________________


More information about the Python-bugs-list mailing list