-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
dis.show_code() variant that accepts source strings (and returns rather than prints) #53393
Comments
Add a new API in the dis module that:
Tentative name: get_code_info() Inspired by Yanov Aknin's ssc() utility and the bpo-6507 updates to dis.dis() |
Yes, please! |
Small correction to my first message: that would be Yaniv Aknin (not Yanov) |
Implemented in r84133 |
Final name was dis.code_info() and it accepts functions, methods, code objects and source strings. |
The buildbot XP-4 3.x fails on test_dis. test_code_info (test.test_dis.CodeInfoTests) ... FAIL ====================================================================== Traceback (most recent call last):
File "D:\cygwin\home\db3l\buildarea\3.x.bolen-windows\build\lib\test\test_dis.py", line 359, in test_code_info
self.assertEqual(dis.code_info(x), expected)
AssertionError: 'Name: tricky\nFilename: D:\\cygwin\\home\\db3l\\buildarea [truncated]... != 'Name: tricky\nFilename: D:\\cygwin\\home\\db3l\\buildarea [truncated]...
Name: tricky
Filename: D:\cygwin\home\db3l\buildarea\3.x.bolen-windows\build\lib\test\test_dis.py
Argument count: 3
Kw-only arguments: 3
Number of locals: 8
Stack size: 7
Flags: OPTIMIZED, NEWLOCALS, VARARGS, VARKEYWORDS, GENERATOR
Constants:
0: None
- 1: <code object f at 0x03D750F8, file "D:\cygwin\home\db3l\buildarea\3.x.bolen-windows\build\lib\test\test_dis.py", line 246>
? - ^ ^
+ 1: <code object f at 0x3d750f8, file "D:\cygwin\home\db3l\buildarea\3.x.bolen-windows\build\lib\test\test_dis.py", line 246>
? ^ ^
Variable names:
0: x
1: y
2: z
3: c
4: d
5: e
6: args
7: kwds
Cell variables:
0: e
1: d
2: f
3: y
4: x
5: z ====================================================================== Traceback (most recent call last):
File "D:\cygwin\home\db3l\buildarea\3.x.bolen-windows\build\lib\test\test_dis.py", line 366, in test_show_code
self.assertEqual(output.getvalue(), expected+"\n")
AssertionError: 'Name: tricky\nFilename: D:\\cygwin\\home\\db3l\\buildarea [truncated]... != 'Name: tricky\nFilename: D:\\cygwin\\home\\db3l\\buildarea [truncated]...
Name: tricky
Filename: D:\cygwin\home\db3l\buildarea\3.x.bolen-windows\build\lib\test\test_dis.py
Argument count: 3
Kw-only arguments: 3
Number of locals: 8
Stack size: 7
Flags: OPTIMIZED, NEWLOCALS, VARARGS, VARKEYWORDS, GENERATOR
Constants:
0: None
- 1: <code object f at 0x03D750F8, file "D:\cygwin\home\db3l\buildarea\3.x.bolen-windows\build\lib\test\test_dis.py", line 246>
? - ^ ^
+ 1: <code object f at 0x3d750f8, file "D:\cygwin\home\db3l\buildarea\3.x.bolen-windows\build\lib\test\test_dis.py", line 246>
? ^ ^
Variable names:
0: x
1: y
2: z
3: c
4: d
5: e
6: args
7: kwds
Cell variables:
0: e
1: d
2: f
3: y
4: x
5: z |
I changed the test to a regex match that ignores the specific ID value of the nested function in r84137. That should make the buildbots happier. |
Switching to a regex match made the backslashes in windows paths a problem. r84139 changes the test to just ignore all the variable info in the code_info results so we'll see how that goes. |
The windows buildbot still doesn't appear to be particularly happy, but this issue also doesn't appear to be the culprit anymore. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: