-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
gh-92886: fixed tests that were breaking while running with basic optimizations enabled (-O, assertions off) #93174
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
Changes from all commits
0f8ae9b
6afde94
0d71b7a
f515d9f
ff6b191
3926165
47a0eb1
1dcb59e
de758bb
afb2620
6edf183
932449f
84563b0
3346ca3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1041,11 +1041,6 @@ def get_disassembly(self, func, lasti=-1, wrapper=True, **kwargs): | |
return output.getvalue() | ||
|
||
|
||
if sys.flags.optimize: | ||
code_info_consts = "0: None" | ||
else: | ||
code_info_consts = "0: 'Formatted details of methods, functions, or code.'" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
code_info_code_info = f"""\ | ||
Name: code_info | ||
Filename: (.*) | ||
|
@@ -1056,7 +1051,7 @@ def get_disassembly(self, func, lasti=-1, wrapper=True, **kwargs): | |
Stack size: \\d+ | ||
Flags: OPTIMIZED, NEWLOCALS | ||
Constants: | ||
{code_info_consts} | ||
0: 'Formatted details of methods, functions, or code.' | ||
Names: | ||
0: _format_code_info | ||
1: _get_code_object | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -939,6 +939,7 @@ def test_with_statement_logout(self): | |
|
||
@threading_helper.reap_threads | ||
@cpython_only | ||
@unittest.skipUnless(__debug__, "Won't work if __debug__ is False") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
def test_dump_ur(self): | ||
# See: http://bugs.python.org/issue26543 | ||
untagged_resp_dict = {'READ-WRITE': [b'']} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -235,11 +235,12 @@ def pycompilecmd(self, *args, **kwargs): | |
# assert_python_* helpers don't return proc object. We'll just use | ||
# subprocess.run() instead of spawn_python() and its friends to test | ||
# stdin support of the CLI. | ||
opts = '-m' if __debug__ else '-Om' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure how this actually fixed things, but it seems to have done the trick 🤷♂️ |
||
if args and args[0] == '-' and 'input' in kwargs: | ||
return subprocess.run([sys.executable, '-m', 'py_compile', '-'], | ||
return subprocess.run([sys.executable, opts, 'py_compile', '-'], | ||
input=kwargs['input'].encode(), | ||
capture_output=True) | ||
return script_helper.assert_python_ok('-m', 'py_compile', *args, **kwargs) | ||
return script_helper.assert_python_ok(opts, 'py_compile', *args, **kwargs) | ||
|
||
def pycompilecmd_failure(self, *args): | ||
return script_helper.assert_python_failure('-m', 'py_compile', *args) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -833,9 +833,8 @@ def func(): | |
(5, 'line'), | ||
(6, 'line'), | ||
(7, 'line'), | ||
(10, 'line'), | ||
(13, 'line'), | ||
(13, 'return')]) | ||
(10, 'line')] + | ||
([(13, 'line'), (13, 'return')] if __debug__ else [(10, 'return')])) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The assertions on line 819 affect the line numbers we are testing here when running with optimizations. |
||
|
||
def test_continue_through_finally(self): | ||
|
||
|
@@ -870,9 +869,8 @@ def func(): | |
(6, 'line'), | ||
(7, 'line'), | ||
(10, 'line'), | ||
(3, 'line'), | ||
(13, 'line'), | ||
(13, 'return')]) | ||
(3, 'line')] + | ||
([(13, 'line'), (13, 'return')] if __debug__ else [(3, 'return')])) | ||
|
||
def test_return_through_finally(self): | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fixed tests that were breaking while running with basic optimizations enabled (-O, assertions off). |
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.
Could be worth fixing the rest of the assertions in this file?