(compiler, source, filename, symbol)
| 84 | |
| 85 | |
| 86 | def _maybe_compile(compiler, source, filename, symbol): |
| 87 | # Check for source consisting of only blank lines and comments |
| 88 | for line in source.split("\n"): |
| 89 | line = line.strip() |
| 90 | if line and line[0] != "#": |
| 91 | break # Leave it alone |
| 92 | else: |
| 93 | if symbol != "eval": |
| 94 | source = "pass" # Replace it with a 'pass' statement |
| 95 | |
| 96 | err = err1 = err2 = None |
| 97 | code = code1 = code2 = None |
| 98 | |
| 99 | try: |
| 100 | code = compiler(source, filename, symbol) |
| 101 | except SyntaxError as err: |
| 102 | pass |
| 103 | |
| 104 | try: |
| 105 | code1 = compiler(source + "\n", filename, symbol) |
| 106 | except SyntaxError as e: |
| 107 | err1 = e |
| 108 | |
| 109 | try: |
| 110 | code2 = compiler(source + "\n\n", filename, symbol) |
| 111 | except SyntaxError as e: |
| 112 | err2 = e |
| 113 | |
| 114 | try: |
| 115 | if code: |
| 116 | return code |
| 117 | if not code1 and repr(err1) == repr(err2): |
| 118 | raise err1 |
| 119 | finally: |
| 120 | err1 = err2 = None |
| 121 | |
| 122 | |
| 123 | def _compile(source, filename, symbol): |
no outgoing calls
no test coverage detected