[issue20015] Allow 1-character ASCII unicode where 1-character str is required

Serhiy Storchaka report at bugs.python.org
Mon Mar 3 22:28:28 CET 2014


Serhiy Storchaka added the comment:

> However, do note that the semantics will end up different from other uses of 
unicode. e.g.:
> >>> "aa".strip(u"b")
> 
> u'aa'

And this behavior is weird.

>>> print 'À\n'.strip('\n')
À
>>> print 'À\n'.strip(u'\n')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: 
ordinal not in range(128)

The self argument of str.strip is variable, but the chars argument is almost  
always a literal and affected by unicode_literals future.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20015>
_______________________________________


More information about the Python-bugs-list mailing list