[issue47023] re.sub shows key error on regex escape chars provided in repl param

2022-03-17 Thread Eric V. Smith
Eric V. Smith added the comment: I agree the error message could be better. Also, "s.error('bad escape %s' % this, len(this))" should probably be "from None", since as @mrabarnett notes the KeyError is an implementation detail. -- ___ Python

[issue47023] re.sub shows key error on regex escape chars provided in repl param

2022-03-17 Thread Matthew Barnett
Matthew Barnett added the comment: I'd just like to point out that to a user it could _look_ like a bug, that an error occurred while reporting, because the traceback isn't giving a 'clean' report; the stuff about the KeyError is an internal detail. --

[issue47023] re.sub shows key error on regex escape chars provided in repl param

2022-03-17 Thread Eric V. Smith
Eric V. Smith added the comment: Yes, I assume that's what the OP intended, but then stumbled across the error with '\s'. In any event, I don't think there's a bug here so I'm going to close this. @siddheshsathe: if you disagree, please respond here. -- resolution: -> not a bug

[issue47023] re.sub shows key error on regex escape chars provided in repl param

2022-03-17 Thread Raymond Hettinger
Raymond Hettinger added the comment: There seem to be a number of escaping problems in the OP's example. Is this what was intended? >>> re.sub(r"\{(\w+)\}", r"\1", "Hello! {user}") 'Hello! user' -- nosy: +rhettinger status: pending -> open ___

[issue47023] re.sub shows key error on regex escape chars provided in repl param

2022-03-17 Thread Eric V. Smith
Change by Eric V. Smith : -- status: open -> pending ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue47023] re.sub shows key error on regex escape chars provided in repl param

2022-03-15 Thread Eric V. Smith
Eric V. Smith added the comment: Isn't '\s' covered by: " Unknown escapes of ASCII letters are reserved for future use and treated as errors" (https://docs.python.org/3/library/re.html#re.sub)? -- nosy: +eric.smith ___ Python tracker

[issue47023] re.sub shows key error on regex escape chars provided in repl param

2022-03-15 Thread Siddhesh Sathe
New submission from Siddhesh Sathe : Python 3.9.10 (main, Jan 15 2022, 18:56:52) [GCC 7.5.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> re.sub(r"{\w}", "\s", "Hello! {user}") Traceback (most recent call last): File