[Python-3000] [Python-Dev] Filename as byte string in python 2.6 or 3.0?

"Martin v. Löwis" martin at v.loewis.de
Tue Sep 30 23:51:18 CEST 2008


> $ ./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.

While I can sympathize with people having non-ASCII file names on their
disks, I can't sympathize with this example. Normal users just don't
put \x90 into their command lines, and those who do deserve the error
message they get.

Regards,
Martin


More information about the Python-3000 mailing list