[Python-3000] [Python-Dev] Filename as byte string in python 2.6 or 3.0?
Nick Coghlan
ncoghlan at gmail.com
Tue Sep 30 23:31:34 CEST 2008
James Y Knight wrote:
> Those aren't good behaviors, and can't be solved simply by pretending
> certain files don't exist.
A couple of output comparisons for two of James's examples (system
Python is 2.5.3, the Python :
$ python -V
Python 2.5.2
$ python -c "import sys; print sys.argv" "$(echo -e 'filename\x90\x90')"
['-c', 'filename\x90\x90']
$ python -c "import os; print os.environ['DUMMY']"
filename??
$ ./python -V
Python 3.0b3+
$ ./python -c "import sys; print(sys.argv)" "$(echo -e 'filename\x90\x90')"
Could not convert argument 3 to str
$ ./python -c "import os; print(os.environ['DUMMY'])"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/ncoghlan/devel/py3k/Lib/os.py", line 389, in __getitem__
return self.data[self.keymap(key)]
KeyError: 'DUMMY'
(Is there a bug report for these yet?)
I'm also starting to wonder if allowing mixed types might be the way to
go for these interfaces - leaving the bytes objects in place if the
Unicode decode operation fails.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
http://www.boredomandlaziness.org
More information about the Python-3000
mailing list