Windows file paths, again
lie.1296 at gmail.com
Wed Oct 21 22:49:06 CEST 2009
Dan Guido wrote:
> Hi Anthony,
> Thanks for your reply, but I don't think your tests have any control
> characters in them. Try again with a \v, a \n, or a \x in your input
> and I think you'll find it doesn't work as expected.
A path read from a file, config file, or winreg would never contain
control characters unless they contains that a control character.
My crystal ball thinks that you used eval or exec somewhere in your
script, which may cause a perfectly escaped path to get unescaped, like
# python 3
path = 'C:\\path\\to\\somewhere.txt'
script = 'open("%s")' % path # this calls str(path)
you stored the path incorrectly. Try seeing what exactly is stored in
the registry using regedit.
Remember that escape characters doesn't really exist in the in-memory
representation of the string. The escape characters exist only in string
literals (i.e. source code) and when you print the string using repr().
More information about the Python-list