Hi, See attached patch: python3_bytes_filename.patch Using the patch, you will get: - open() support bytes - listdir(unicode) -> only unicode, *skip* invalid filenames (as asked by Guido) - remove os.getcwdu() - create os.getcwdb() -> bytes - glob.glob() support bytes - fnmatch.filter() support bytes - posixpath.join() and posixpath.split() support bytes Mixing bytes and str is invalid. Examples raising a TypeError: - posixpath.join(b'x', 'y') - fnmatch.filter([b'x', 'y'], '*') - fnmatch.filter([b'x', b'y'], '*') - glob.glob1('.', b'*') - glob.glob1(b'.', '*') $ diffstat ~/python3_bytes_filename.patch Lib/fnmatch.py | 7 +++- Lib/glob.py | 15 ++++++--- Lib/io.py | 2 - Lib/posixpath.py | 20 ++++++++---- Modules/posixmodule.c | 83 ++++++++++++++++++-------------------------------- 5 files changed, 62 insertions(+), 65 deletions(-) TODO: - review this patch :-) - support non-ASCII bytes in fnmatch.filter() - fix other functions, eg. posixpath.isabs() and fnmatch.fnmatchcase() - fix functions written in C: grep FileSystemDefaultEncoding - make sure that mixing bytes and str is rejected -- Victor Stinner aka haypo http://www.haypocalc.com/blog/ -------------- next part -------------- A non-text attachment was scrubbed... Name: python3_bytes_filename.patch Type: text/x-diff Size: 6732 bytes Desc: not available URL: <http://mail.python.org/pipermail/python-dev/attachments/20080930/e8998338/attachment.patch>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4