| 202 | compile(tree, "<string>", "exec") |
| 203 | |
| 204 | def test_negative_locations_for_compile(self): |
| 205 | # See https://github.com/python/cpython/issues/130775 |
| 206 | alias = ast.alias(name='traceback', lineno=0, col_offset=0) |
| 207 | for attrs in ( |
| 208 | {'lineno': -2, 'col_offset': 0}, |
| 209 | {'lineno': 0, 'col_offset': -2}, |
| 210 | {'lineno': 0, 'col_offset': -2, 'end_col_offset': -2}, |
| 211 | {'lineno': -2, 'end_lineno': -2, 'col_offset': 0}, |
| 212 | ): |
| 213 | with self.subTest(attrs=attrs): |
| 214 | tree = ast.Module(body=[ |
| 215 | ast.Import(names=[alias], **attrs) |
| 216 | ], type_ignores=[]) |
| 217 | |
| 218 | # It used to crash on this step: |
| 219 | compile(tree, "<string>", "exec") |
| 220 | |
| 221 | # This also must not crash: |
| 222 | ast.parse(tree, optimize=2) |
| 223 | |
| 224 | def test_docstring_optimization_single_node(self): |
| 225 | # https://github.com/python/cpython/issues/137308 |