Python3.3 str() bug?

Terry Reedy tjreedy at
Sat Nov 10 00:35:46 CET 2012

On 11/9/2012 8:13 AM, Helmut Jarausch wrote:

> Just for the record.
> I first discovered a real bug with Python3 when using os.walk on a file system
> containing non-ascii characters in file names.
> I encountered a very strange behavior (I still would call it a bug) when trying
> to put non-ascii characters in email headers.
> This has only been solved satisfactorily in Python3.3.

Most bugs, such as the above, are in library modules. There have been 
many related to unicode. In my opinion, 3.3 is the first version to 
handle unicode decently well.

>>> How can I convert a data strucure of arbitrarily complex nature, which contains
>>> bytestrings somewhere, to a string?

> Thanks, but in my case the (complex) object is returned via ctypes from the
> aspell library.
> I still think that a standard function in Python3 which is able to 'stringify'
> objects should take an encoding parameter.

This is an interesting idea, which I have not seen before. It is more 
sensible in Python 3 than in Python 2. (For py2, unicode(str(object), 
encoding='xxx') does what you want.) Try presenting it here or on 
python-ideas as an enhancement request, rather than as a bug report ;-).

In the meanwhile, if you cannot have the object constructed with strings 
rather than bytes, I suggest you write a custom converter function that 
understands the structure and replaces bytes with strings.

Terry Jan Reedy

More information about the Python-list mailing list