Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 35.2k
gh-107450: Check for overflow in the tokenizer and fix overflow test#110832
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
Merged
lysnikolaou
merged 6 commits into
python:main
from
lysnikolaou:overflow-error-col-offsetOct 16, 2023
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
16d508d
gh-107450: Check for overflow in the tokenizer and fix overflow test
lysnikolaou c8433ca
Address some feedback
lysnikolaou e4a059e
Address more feedback
lysnikolaou 5d7c5a6
Formatting
lysnikolaou 66d94be
More feedback
lysnikolaou f20b95f
Use bytes for source
lysnikolaou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -18,6 +18,12 @@ | ||
| from test.support.warnings_helper import check_warnings | ||
| from test import support | ||
| try: | ||
| from _testcapi import INT_MAX | ||
| except ImportError: | ||
| INT_MAX = 2**31 - 1 | ||
| class NaiveException(Exception): | ||
| def __init__(self, x): | ||
| @@ -318,11 +324,13 @@ def baz(): | ||
| check('(yield i) = 2', 1, 2) | ||
| check('def f(*):\n pass', 1, 7) | ||
| @unittest.skipIf(INT_MAX >= sys.maxsize, "Downcasting to int is safe for col_offset") | ||
| @support.requires_resource('cpu') | ||
| @support.bigmemtest(support._2G, memuse=1.5) | ||
| def testMemoryErrorBigSource(self, _size): | ||
| with self.assertRaises(OverflowError): | ||
| exec(f"if True:\n {' ' * 2**31}print('hello world')") | ||
| @support.bigmemtest(INT_MAX, memuse=2, dry_run=False) | ||
| def testMemoryErrorBigSource(self, size): | ||
lysnikolaou marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| src = b"if True:\n%*s" % (size, b"pass") | ||
| with self.assertRaisesRegex(OverflowError, "Parser column offset overflow"): | ||
| compile(src, '<fragment>', 'exec') | ||
| @cpython_only | ||
| def testSettingException(self): | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Uh oh!
There was an error while loading. Please reload this page.