414 @param co reference to the code object to generate the info for |
414 @param co reference to the code object to generate the info for |
415 @type code |
415 @type code |
416 @return dictionary containing the code info data |
416 @return dictionary containing the code info data |
417 @rtype dict |
417 @rtype dict |
418 """ |
418 """ |
419 return { |
419 codeInfoDict = { |
420 "name": co.co_name, |
420 "name": co.co_name, |
421 "filename": co.co_filename, |
421 "filename": co.co_filename, |
422 "firstlineno": co.co_firstlineno, |
422 "firstlineno": co.co_firstlineno, |
423 "argcount": co.co_argcount, |
423 "argcount": co.co_argcount, |
424 "posonlyargcount": co.co_posonlyargcount, |
|
425 "kwonlyargcount": co.co_kwonlyargcount, |
424 "kwonlyargcount": co.co_kwonlyargcount, |
426 "nlocals": co.co_nlocals, |
425 "nlocals": co.co_nlocals, |
427 "stacksize": co.co_stacksize, |
426 "stacksize": co.co_stacksize, |
428 "flags": dis.pretty_flags(co.co_flags), |
427 "flags": dis.pretty_flags(co.co_flags), |
429 "consts": [str(const) for const in co.co_consts], |
428 "consts": [str(const) for const in co.co_consts], |
430 "names": [str(name) for name in co.co_names], |
429 "names": [str(name) for name in co.co_names], |
431 "varnames": [str(name) for name in co.co_varnames], |
430 "varnames": [str(name) for name in co.co_varnames], |
432 "freevars": [str(var) for var in co.co_freevars], |
431 "freevars": [str(var) for var in co.co_freevars], |
433 "cellvars": [str(var) for var in co.co_cellvars], |
432 "cellvars": [str(var) for var in co.co_cellvars], |
434 } |
433 } |
|
434 try: |
|
435 codeInfoDict["posonlyargcount"] = co.co_posonlyargcount |
|
436 except AttributeError: |
|
437 # does not exist prior to 3.8.0 |
|
438 codeInfoDict["posonlyargcount"] = 0 |
435 |
439 |
436 def __loadDIS(self): |
440 def __loadDIS(self): |
437 """ |
441 """ |
438 Private method to generate the Disassembly from the source of the |
442 Private method to generate the Disassembly from the source of the |
439 current editor and visualize it. |
443 current editor and visualize it. |