Skip to content

BUG: newbytes objects (future.builtins.str objects) are wrongly repred by unidecode #13

Open
@hobson

Description

@hobson

Punchline: from builtins import str; str(unidecode(str('2b or not 2b')))

"b'2b or not 2b'"

>>> from unidecode import unidecode
>>> str(unidecode(str('2b or not 2b')))  # no problem
'2b or not 2b'
>>> from builtins import str
>>> str(unidecode(str('2b or not 2b')))  # big problem
"b'2b or not 2b'"
>>> str(str('2b or not 2b'))  # str recursively all you want
'2b or not 2b'
>>> unidecode(str('2b or not 2b'))  # `newbyte` obj is `repr`ed by unidecode
b'2b or not 2b'
>>> unidecode('2b or not 2b')
'2b or not 2b'
>>> unidecode(unidecode('2b or not 2b'))
'2b or not 2b'
>>> unidecode(unidecode(b'2b or not 2b'))
'2b or not 2b'
>>> unidecode(unidecode(str('2b or not 2b')))  # because future.builtins creates a newbytes type
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
...
AttributeError: encode method has been disabled in newbytes
>>> unidecode(str('2b or not 2b'))
b'2b or not 2b'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions