Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyRun_SimpleString won't parse \\x #42849

Closed
gnupun mannequin opened this issue Jan 30, 2006 · 2 comments
Closed

PyRun_SimpleString won't parse \\x #42849

gnupun mannequin opened this issue Jan 30, 2006 · 2 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@gnupun
Copy link
Mannequin

gnupun mannequin commented Jan 30, 2006

BPO 1418374

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2006-01-30.16:16:45.000>
created_at = <Date 2006-01-30.07:43:56.000>
labels = ['interpreter-core', 'invalid']
title = "PyRun_SimpleString won't parse \\\\x"
updated_at = <Date 2006-01-30.16:16:45.000>
user = 'https://bugs.python.org/gnupun'

bugs.python.org fields:

activity = <Date 2006-01-30.16:16:45.000>
actor = 'effbot'
assignee = 'none'
closed = True
closed_date = None
closer = None
components = ['Interpreter Core']
creation = <Date 2006-01-30.07:43:56.000>
creator = 'gnupun'
dependencies = []
files = []
hgrepos = []
issue_num = 1418374
keywords = []
message_count = 2.0
messages = ['27386', '27387']
nosy_count = 2.0
nosy_names = ['effbot', 'gnupun']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue1418374'
versions = ['Python 2.4']

@gnupun
Copy link
Mannequin Author

gnupun mannequin commented Jan 30, 2006

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

@gnupun gnupun mannequin closed this as completed Jan 30, 2006
@gnupun gnupun mannequin added invalid interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Jan 30, 2006
@gnupun gnupun mannequin closed this as completed Jan 30, 2006
@gnupun gnupun mannequin added invalid interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Jan 30, 2006
@effbot
Copy link
Mannequin

effbot mannequin commented Jan 30, 2006

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.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)
Projects
None yet
Development

No branches or pull requests

0 participants