Issue 2. 73. 64: Deprecate invalid escape sequences in str/bytes. Created on 2. 01. Chi Hsuan Yen. This issue is now closed. File name. Uploaded. Description. Editdeprecate.
The point of this is to prevent issues such as #2. Ultimately, I decided to leave bytes alone for now, since it's mostly on the lower- level side of things. If there's interest I can add it back. Author: R. David Murray (r. Date: 2. 01. 6- 0. Have you searched the python- dev and python- ideas archives for the previous discussions of this issue? I found nothing on Python- Dev, but apparently it's been discussed on Python- ideas before: https: //mail.
August/0. 35. 03. Guido hasn't participated in that discussion, and most of it was . Seems to be in use in Python standard library as well, for example in csv. Author: Emanuel Barry (ebarry) *Date: 2. Yes, it's in use in an awful lot of places (see my patch). The proper fix is to use raw strings, or, if you need actual escapes in the same string, manually escape them.
However, as you'll see by looking at the patch, the vast majority of cases are fixed by prepending a single 'r' to the front of the string. In fact, only csv. I've always used raw strings for regular expressions, and this patch would simply move this from being a style issue to being a syntax one (and I think it's fine : ). Author: Serhiy Storchaka (serhiy. Date: 2. 01. 6- 0. There was a long discussion on Python- Dev.
Apparently Guido's stance is . Patch attached (also with Serhiy's comments). Ok, it worries me a lot. Please don't merge this until it's fixed.
A patch for this bug has.
I'm guessing this is a combination of unittest catching warnings and compiling the faulty source file. As to why a malformed node (i. It doesn't have to be two releases, I just mean two separate commits: (1) fix all places in the stdlib that violate this principle; (2) separately commit the code that causes the silent deprecation (and tests for it).
Do you think it was a bug in your own C code or in existing C code? Author: Emanuel Barry (ebarry) *Date: 2. I originally considered making two different patches, so there you go. One stdlib module (I don't remember which one) had one single invalid escape sequence in it, and then test.
You receive an 'Invalid Patch File Error' error message when you install Rise of. Install Rise of Nations: Thrones and Patriots if it is not installed. Warning: Missing argument 2 for. Report Type is Missing or Invalid. This is not an invalid bug.
Patch Warning Missing or Invalid Registry/INI entry : Sample Dialog. Patch Warning : Body Text : Missing or Invalid Registry/INI entry : Typical location : C. Patch Warning - Missing or Invalid Registry/INI entry Application Issues : Advanced Search ?
LDD7 update - missing or invalid Registry / INI entry. If Chief Architect is running. The VMware Knowledge Base provides support solutions. Patch Category : Bugfix: Patch Severity. WARNING: VisorFSObj: 893.
Fixing the invalid escape removes the failure and all tests pass. Should I open another issue for that? Author: Guido van Rossum (gvanrossum) *Date: 2. Hm, if you manage to trigger an assert() in the C code by writing some evil. Python code, the C code is considered broken (unless it was using ctypes or. In general the error . IIRC only debug mode checks for that.
But you shouldn't assume. Author: Emanuel Barry (ebarry) *Date: 2. Ah right, assert() is only enabled in debug mode, I forgot that. My (very uneducated) guess is that compile() got the error (which was a warning) but then decided to return a value anyway, and the next thing that tries to call anything crashes Python. I opened #2. 73. 94 to get some experts' advice. Author: Emanuel Barry (ebarry) *Date: 2. Aaand I feel pretty stupid; I didn't check the return value of Py.
Err. Attached new patch, actually done right this time. Author: Martin Panter (martin. Date: 2. 01. 6- 0. Hello Emanual, I think I have fixed your problem with - Werror, by handling the exception returned by Py. Err. Thanks for separating the actual change from the escape violation fixes; it made it easier to spot the real problem : ). Also, I like the general idea of the change. It would be good to update the documentation as well (e.
What’s New, and < https: //docs. What did you try so far? Do you have a partial patch for it? Author: Martin Panter (martin.
Date: 2. 01. 6- 0. Hah, we posted the same fix almost at the same time : )msg. Author: Emanuel Barry (ebarry) *Date: 2. Indeed, we did, thanks for letting me know my mistake : ) I didn't get very far into making bytes literal disallow invalid sequences, as I ran into issues with .
I'll see if I can make literals warn but not e. I think you can run “make - C Doc doctest” or something similar, which may help find some of these. Not sure if that is a problem, but it probably deserves also documenting the change. Author: STINNER Victor (haypo) *Date: 2. Guido: . It is possible to get an exception using python. Werror. It becomes an error in the future.
Future. Warning is used when we want change the meaning of a feature instead of removing it. For example re. split(': *', 'a: bc') emits a Future. Warning and returns . Since there is no haste, we should use 2- releases deprecation period.
After this a deprecation can be changed to a Synatax. Warning in 3. 8 and to a Unicode.
Decode. Error (for strings) and a Value. Error (for bytes) in 4. The latter are converted to Syntax. Error by parser. At the end we should get the same behavior as for truncated \x and \u escapes. I don't know *when* it becomes appropriate to change a warning into an error; I was thinking 3.
Serhiy said, there's no rush. I think waiting five release cycles is overkill though, that means the error won't be until 8 years from now (assuming release cycle periods don't change)! I think at most 3. Author: STINNER Victor (haypo) *Date: 2. To move faster, you should also worker with linters (pylint, pychecker, pyflakes, pycodestyle, flake. David Murray (r. david.
Date: 2. 01. 6- 0. Yes, this change is likely to break a lot of code, so an extended deprecation period (certainly longer than 3.
Guido has already mandated) is the minimum). But because there's so. I'll contact the Py.
CQA people later today when I'm back home. I don't really have a strong opinion when exactly that should happen. Author: Emanuel Barry (ebarry) *Date: 2. Just brought this to the attention of the code- quality mailing list, so linter maintainers should (hopefully!) catch up soon. Tests included with test.
There are plenty of test suite failures; I ran the test suite with approximately the following. Werror - m test - Wr - j. Let me know if you want the full details.
Some of these are brand new, though, so thanks! I'll run and fix the tests (and modules as well); should likely have a patch by the weekend : )msg.
Author: Emanuel Barry (ebarry) *Date: 2. Here's a new pair of patches for this.
There are some small tweaks to the tests, and I properly fixed all instances of invalid escapes (I also made some strings into raw- strings at some places where it's not needed, solely for consistency with surrounding lines or functions). The patch that fixes the invalid escapes is four times larger than the previous one. I'd like to get this merged in time for 3. Is there anything I can do to speed up the review? There's a few file tweaks here and there to stay up to date, otherwise it's mostly the same.
I'd rather have the other issues addressed in another issue, as I want to get this merged in time for the feature freeze. The other issues (some which were already present) can be taken care of during the beta phase. Author: Emanuel Barry (ebarry) *Date: 2. Rebased patch after Victor's commit in #1.
Also regenerated invalid. Who can help reviewing and merging before beta 1? Author: Emanuel Barry (ebarry) *Date: 2. Thank you R. David for the review, here's a new patch with the one change.
Author: Serhiy Storchaka (serhiy. Date: 2. 01. 6- 0.
I suggest to not change fixcid. It is not correct and there is special issue for this (issue. Author: Emanuel Barry (ebarry) *Date: 2. All right, since you'll work on it I'm leaving it out.
David Murray (r. david. Date: 2. 01. 6- 0. Here's a copy of Emanuel's deprecation patch with a versionchanged note in the lexical docs and a whatsnew entry. Author: Roundup Robot (python- dev)Date: 2.
New changeset 3. 88. R David Murray in branch 'default'. Deprecate invalid escape strings in str/byutes. David Murray (r. david. Date: 2. 01. 6- 0. Thanks Emanuel. Reedy (terry.
Date: 2. 01. 6- 0. Thank you all for persisting on this. For example, I have two files foo. W error foo. py. Traceback (most recent call last). File . I have to add some codes to show which module is imported.
Raising Syntax. Error may not be a good idea, anyway. Author: Emanuel Barry (ebarry) *Date: 2. Fair enough, but please open a new issue for that.