-
-
Notifications
You must be signed in to change notification settings - Fork 33.3k
gh-139531: Fix TypeError in inspect.getframeinfo when lineno is None #139535
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
3b96cc9
92e87c2
24361e4
e74e210
fb3b712
d333123
574461d
1c831c3
c1a282b
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 |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ | |
| import unittest.mock | ||
| import warnings | ||
| import weakref | ||
| import unittest | ||
|
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. Why reimporting this? |
||
|
|
||
|
|
||
| try: | ||
|
|
@@ -6245,8 +6246,22 @@ def f(): | |
| expected = "The source is: <<<def f():\n print(0)\n return 1 + 2\n>>>" | ||
| self.assertIn(expected, output) | ||
|
|
||
|
|
||
|
|
||
| class TestInspect(unittest.TestCase): | ||
|
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. Why a new class? |
||
| def test_getframeinfo_with_exceptiongroup(self): | ||
| code = """ | ||
| try: | ||
| 1/0 | ||
| except* Exception: | ||
| raise | ||
| """ | ||
| with self.assertRaises(TypeError): # expect the bug to raise TypeError | ||
| try: | ||
| exec(code) | ||
| except: | ||
| tb = sys.exc_info()[2] | ||
| while tb: | ||
| info = inspect.getframeinfo(tb.tb_frame) | ||
| tb = tb.tb_next | ||
|
Comment on lines
+6257
to
+6264
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. What is this test? we should fix the issue, not show that there is one. |
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Fix TypeError in inspect.getframeinfo when lineno is None (gh-139531, #139535). |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| gh-139531: Fix TypeError in inspect.getframeinfo when lineno is None #139535 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| ../../Lib/_colorize.py | ||
| ../../Lib/_colorize.py | ||
|
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. What are all these changes? |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| ../../Lib/token.py | ||
| ../../Lib/token.py |
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.
Why this change? it might happen that lineno is None and should remains so.