Attempts to compile the given source, first as an expression and then as a statement if the first approach fails. Utility function to accept strings in functions that otherwise expect code objects
(source, name)
| 70 | } |
| 71 | |
| 72 | def _try_compile(source, name): |
| 73 | """Attempts to compile the given source, first as an expression and |
| 74 | then as a statement if the first approach fails. |
| 75 | |
| 76 | Utility function to accept strings in functions that otherwise |
| 77 | expect code objects |
| 78 | """ |
| 79 | try: |
| 80 | return compile(source, name, 'eval') |
| 81 | except SyntaxError: |
| 82 | pass |
| 83 | return compile(source, name, 'exec') |
| 84 | |
| 85 | def dis(x=None, *, file=None, depth=None, show_caches=False, adaptive=False, |
| 86 | show_offsets=False, show_positions=False): |
no test coverage detected