This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: os.listdir doc should mention that Unicode decoding can fail
Type: behavior Stage:
Components: Documentation, Library (Lib), Unicode Versions: Python 2.7, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: brodie, georg.brandl, loewis, pitrou, vstinner
Priority: normal Keywords:

Created on 2008-05-15 01:16 by brodie, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg66839 - (view) Author: Brodie Rao (brodie) Date: 2008-05-15 01:16
The documentation for os.listdir should mention that there's a 
possibility that it can fail to decode paths to unicode objects and that 
it returns str objects for those paths it couldn't decode.

The documentation should also explain when this might happen, and 
perhaps how to deal with it. The cases that this could happen or how to 
work around it are beyond my knowledge, but #683592 does mention 
something about resetting the locale. I don't know if that comment is 
still relevant, or if it applies to all cases of decoding failure, 
however.

I don't know if this behavior still exists in Python 2.6. If it does, 
the documentation for 2.6 should be amended as well.
msg87628 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-05-12 13:31
Is it about 2.6 or 3.0/3.1? This problem should have been solved in 3.1,
by the way of special escaping for undecodable characters (that is,
os.listdir() will always return strings rather than bytes objects, but
some of those strings may have special escapes in them).
msg87881 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-05-16 11:21
Fixed in r72678.
History
Date User Action Args
2022-04-11 14:56:34adminsetgithub: 47105
2009-05-16 11:21:40georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg87881
2009-05-12 18:22:47loewissetversions: + Python 2.7, - Python 3.1
2009-05-12 13:31:13pitrousetnosy: + pitrou
messages: + msg87628
2009-05-12 12:53:11ajaksu2setpriority: normal
nosy: + loewis, vstinner

components: + Library (Lib), Unicode
versions: + Python 2.6, Python 3.1, - Python 2.5, Python 2.4, Python 2.3
2008-05-15 01:16:47brodiecreate