Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

bpo-37367: octal escapes applied inconsistently throughout the interpreter and lib#14654

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
websurfer5 wants to merge2 commits intopython:mainfromwebsurfer5:fix-issue-37367

Conversation

@websurfer5
Copy link
Contributor

@websurfer5websurfer5 commentedJul 9, 2019
edited by bedevere-bot
Loading

Add a range check for octal values in byte strings that raises ValueError if the value is more than 255 (0o377).

Tests for all 1-, 2-, and 3-digit octal values are provided (both valid and error cases).

https://bugs.python.org/issue37367

Copy link
Contributor

@jdemeyerjdemeyer left a comment

Choose a reason for hiding this comment

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

Looks good, apart from a few nitpicks.

@brettcannonbrettcannon added the type-bugAn unexpected behavior, bug, or error labelJul 11, 2019
1. use "octal escape sequences" instead of "octal values" in comments2. remove underscore from _literal_evalAlso, use "0o1000-0o400" instead of "256" to make it clear to the readerwhere the value came from.
@@ -0,0 +1,2 @@
Byte strings containing octal escape sequences with values greater than 255
will now raise ValueError. Patch by Jeffrey Kintscher.
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be helpful to mention the previous behavior here.

serhiy-storchaka reacted with thumbs up emoji
importtempfile
importtextwrap
importunittest
importast
Copy link
Contributor

Choose a reason for hiding this comment

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

Please keep the imports sorted alphabetically.

serhiy-storchaka reacted with thumbs up emoji
@taleinat
Copy link
Contributor

@websurfer5, could you merge the master branch into this PR's branch, resolving the merge conflicts?

Copy link
Member

@serhiy-storchakaserhiy-storchaka left a comment

Choose a reason for hiding this comment

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

Please add also a not in the What's New document. Since it is a breaking change it should be in section "Porting to Python 3.11".

c=b.translate(None,delete=b'e')
self.assertEqual(c,b'hllo')

deftest_octal_values(self):

Choose a reason for hiding this comment

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

It is not correct place for such test. This file is for tests of bytes and bytearray methods, not parsing Python code.

test_string_literals is for parsing string and bytes literals. Add some tests there.

check(br"[\101]",b"[A]")
check(br"[\1010]",b"[A0]")
check(br"[\501]",b"[A]")
self.assertRaises(ValueError,decode,br"[\501]")

Choose a reason for hiding this comment

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

Move it to test_errors below.

}
if (c>255) {
PyErr_Format(PyExc_ValueError,
"octal value must be in range(0, 256)");

Choose a reason for hiding this comment

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

The error message should contain the position of the invalid octal escape sequence. It would be nice if look similar to error message for invalid hexadecimal escape sequence. For example:

"invalid octal escape sequence at position %zd"

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phraseI have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@serhiy-storchaka
Copy link
Member

#91668 was merged instead.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@taleinattaleinattaleinat left review comments

@jdemeyerjdemeyerjdemeyer requested changes

@serhiy-storchakaserhiy-storchakaserhiy-storchaka requested changes

Assignees

No one assigned

Labels

awaiting changestype-bugAn unexpected behavior, bug, or error

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

8 participants

@websurfer5@taleinat@bedevere-bot@serhiy-storchaka@jdemeyer@brettcannon@the-knights-who-say-ni@ezio-melotti

[8]ページ先頭

©2009-2025 Movatter.jp