Paul Moore <p.f.mo...@gmail.com>: > On 1 June 2018 at 13:15, Barry Scott <ba...@barrys-emacs.org> wrote: >> Once you know that all of the string you provided is given to the >> operating system it can then do whatever checks it sees fit to and >> return a suitable result. > > As the programmer, I don't care. The Python interpreter should take > care of that for me, and if I say "does file 'a\0b' exist?" I want an > answer. And I don't see how anything other than "no it doesn't" is > correct. Python allows strings with embedded \0 characters, so it's > possible to express that question in Python - os.path.exists('a\0b'). > What can be expressed in terms of the low-level (C-based) operating > system API shouldn't be relevant.
Interestingly, you get a False even for existing files if you don't have permissions to access the file. Arguably, that answer is misleading, and an exception would be justified. But since os.path.exists() returns a False even in that situation, it definitely should return False for a string containing a NUL character. Marko -- https://mail.python.org/mailman/listinfo/python-list