[New-bugs-announce] [issue18522] Error creating a raw string of r'\\?\'

John Jefferies report at bugs.python.org
Sun Jul 21 20:54:41 CEST 2013


New submission from John Jefferies:

I'm having trouble with a raw string of r'\\?\' as in the following session:
----------------
>>> a = r'\\?\'
  File "<stdin>", line 1
    a = r'\\?\'
              ^
SyntaxError: EOL while scanning string literal
----------------

which seems like a bug to me. I see the same behaviour in v3.3, v3.2, and v2.6. I have tried searching for such a bug but search engines don't work well with a string of non-alphanumerics.

Why is this string important? It's because the Win32 API functions throw an error with path names longer than 260 chars unless the path names are prefixed with this string, e.g:
    shutil.copy2(r'\\?\C:\some\quite\long\path\name', dstname)
    shutil.copy2(r'\\?\' + r'C:\some\quite\long\path\name', dstname)

where the first example throws an exception without the path name prefix; while the second example fails to compile.

FTR. I can create the desired string in various other ways:
----------------
>>> a = '\\\\?\\'
>>> a
'\\\\?\\'
>>> a = r'\\?\ '[0:4]
>>> a
'\\\\?\\'
>>>
----------------

Thanks

John

----------
components: Interpreter Core
messages: 193462
nosy: John.Jefferies
priority: normal
severity: normal
status: open
title: Error creating a raw string of r'\\?\'
type: compile error
versions: Python 2.6, Python 3.2, Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18522>
_______________________________________


More information about the New-bugs-announce mailing list