Return the object corresponding to expression evaluated in a namespace spanning sys.modules and __main.dict__.
(expression)
| 131 | |
| 132 | |
| 133 | def get_entity(expression): |
| 134 | """Return the object corresponding to expression evaluated |
| 135 | in a namespace spanning sys.modules and __main.dict__. |
| 136 | """ |
| 137 | if expression: |
| 138 | namespace = {**sys.modules, **__main__.__dict__} |
| 139 | try: |
| 140 | return eval(expression, namespace) # Only protect user code. |
| 141 | except BaseException: |
| 142 | # An uncaught exception closes idle, and eval can raise any |
| 143 | # exception, especially if user classes are involved. |
| 144 | return None |
| 145 | |
| 146 | # The following are used in get_argspec and some in tests |
| 147 | _MAX_COLS = 85 |
no outgoing calls
no test coverage detected
searching dependent graphs…