Issue 1418374: PyRun_SimpleString won't parse \x (original) (raw)

Issue1418374

Created on 2006-01-30 07:43 by gnupun, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg27386 - (view) Author: gnupun (gnupun) Date: 2006-01-30 07:43
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
msg27387 - (view) Author: Fredrik Lundh (effbot) * (Python committer) Date: 2006-01-30 16:16
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.
History
Date User Action Args
2022-04-11 14:56:15 admin set github: 42849
2006-01-30 07:43:56 gnupun create