[ python-Bugs-1418374 ] PyRun_SimpleString won't parse \\x
SourceForge.net
noreply at sourceforge.net
Mon Jan 30 17:16:45 CET 2006
Bugs item #1418374, was opened at 2006-01-30 08:43
Message generated for change (Comment added) made by effbot
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1418374&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Parser/Compiler
Group: Python 2.4
>Status: Deleted
>Resolution: Invalid
Priority: 5
Submitted By: gnupun (gnupun)
Assigned to: Nobody/Anonymous (nobody)
Summary: PyRun_SimpleString won't parse \\x
Initial Comment:
I'm trying to use Python 2.4.2 from C on Win XP.
The following line of C code generates an error:
test.c:
PyRun_SimpleString( "s = 'C:\\xyz'\n" );
Output:
ValueError: invalid \x escape
The error message only occurs if 'x' follows the
slashes '\\x'. That is, no other letter causes this
problem:
PyRun_SimpleString( "s = 'C:\\ayz'\n" );
PyRun_SimpleString( "s = 'C:\\yyz'\n" );
Using forward slashes also prevents the error:
PyRun_SimpleString( "s = "C:/xyz'\n" ); // ok
----------------------------------------------------------------------
>Comment By: Fredrik Lundh (effbot)
Date: 2006-01-30 17:16
Message:
Logged In: YES
user_id=38376
> The following line of C code generates an error
C uses the same escape rules as Python, so your first
test snippet looks like "C:\xyz" to Python. which is
is an invalid string literal, just as the message says.
see the Python language reference to details on string
literal syntax.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1418374&group_id=5470
More information about the Python-bugs-list
mailing list