GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-32912: Upgrade warning for invalid escape sequences from silent to non-silent by Vgr255 · Pull Request #5849 · python/cpython

Conversation

@Vgr255

@Vgr255 Vgr255 commented Feb 24, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

What the title says. Properly tested and ready for 3.8!

https://bugs.python.org/issue32912

:EDIT:

I don't know how to add a NEWS entry, but I have to go for now. I'll look into that tomorrow.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Vgr255
bpo-32912: Upgrade warning for invalid escape sequences from silent t…
a49a5ee
…o non-silent
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Feb 24, 2018
@bedevere-bot bedevere-bot added the awaiting review label Feb 24, 2018
serhiy-storchaka
serhiy-storchaka reviewed Feb 24, 2018
View reviewed changes
Comment thread Python/ast.c
NULL, NULL) < 0)
{
if (PyErr_ExceptionMatches(PyExc_DeprecationWarning)) {
if (PyErr_ExceptionMatches(PyExc_SyntaxWarning)) {

@serhiy-storchaka serhiy-storchaka Feb 24, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the comment below.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Vgr255 Vgr255 Feb 24, 2018

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the end goal here is to get a SyntaxError, however this is not yet possible as we have to wait for two releases before this can happen, so we can't yet convert it to a SyntaxError. I probably should update that comment, though (I'll do that tomorrow when I get home).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Objects/unicodeobject.c
return NULL;
if (first_invalid_escape != NULL) {
if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
if (PyErr_WarnFormat(PyExc_SyntaxWarning, 1,

@serhiy-storchaka serhiy-storchaka Feb 24, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not related to syntax.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Vgr255 Vgr255 Feb 24, 2018

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This warning was added back in 3.6 when we started deprecating the invalid escapes. In 3.8, we're upgrading these to SyntaxWarning so that they're no longer silent by default, and it will eventually be a SyntaxError. The end goal here is to raise a SyntaxError for this use, but this will have to wait for two more releases.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@serhiy-storchaka serhiy-storchaka Feb 24, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This warning is emitted by the "unicode-escape" codec.

>>> b'\\z'.decode('unicode-escape')
__main__:1: DeprecationWarning: invalid escape sequence '\z'
'\\z'

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Vgr255 Vgr255 Feb 24, 2018

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and this warning was added as part of bpo-27364 to keep consistency with the rest of the language. It only makes sense to upgrade this warning along with everything else, or else this codec falls out of sync with the rest of the language.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Objects/bytesobject.c
return NULL;
if (first_invalid_escape != NULL) {
if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
if (PyErr_WarnFormat(PyExc_SyntaxWarning, 1,

@serhiy-storchaka serhiy-storchaka Feb 24, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not related to syntax.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Vgr255 Vgr255 Feb 24, 2018

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This warning was added back in 3.6 when we started deprecating the invalid escapes. In 3.8, we're upgrading these to SyntaxWarning so that they're no longer silent by default, and it will eventually be a SyntaxError. The end goal here is to raise a SyntaxError for this use, but this will have to wait for two more releases.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@serhiy-storchaka serhiy-storchaka Feb 24, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this warning is emitted by codecs.escape_decode() (which is used in pickle).

>>> codecs.escape_decode(b'\\z')
__main__:1: DeprecationWarning: invalid escape sequence '\z'
(b'\\z', 2)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Vgr255 Vgr255 Feb 24, 2018

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and this warning was added as part of bpo-27364 to keep consistency with the rest of the language. It only makes sense to upgrade this warning along with everything else, or else the codecs module falls out of sync with the rest of the language.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@serhiy-storchaka serhiy-storchaka added awaiting changes and removed awaiting review labels Mar 4, 2018
serhiy-storchaka
serhiy-storchaka requested changes Mar 27, 2018
View reviewed changes

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The codecs module shouldn't raise SyntaxWarning or SyntaxError. It should raise DeprecationWarning, which later will be converted to UnicodeDecodeError.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Vgr255

Vgr255 commented Mar 27, 2018

Copy link
Copy Markdown
Contributor Author

I haven't had the time to work on this, sorry! I'll get back to it hopefully sometime soon.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tirkarthi

tirkarthi commented May 16, 2019

Copy link
Copy Markdown
Member

I think this was done with #9652 and the bpo issue is also marked as resolved.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka serhiy-storchaka closed this May 16, 2019
@Vgr255 Vgr255 mannequin mentioned this pull request Nov 2, 2022
Raise non-silent warning for invalid escape sequences #77093
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@serhiy-storchaka serhiy-storchaka serhiy-storchaka requested changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting changes

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@Vgr255 @tirkarthi @serhiy-storchaka @the-knights-who-say-ni @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.