Report internal error and exit. This optionally starts pdb or shows a traceback.
(
err: Exception,
file: str | None,
line: int,
errors: Errors | None,
options: Options,
stdout: TextIO | None = None,
stderr: TextIO | None = None,
)
| 1322 | |
| 1323 | |
| 1324 | def report_internal_error( |
| 1325 | err: Exception, |
| 1326 | file: str | None, |
| 1327 | line: int, |
| 1328 | errors: Errors | None, |
| 1329 | options: Options, |
| 1330 | stdout: TextIO | None = None, |
| 1331 | stderr: TextIO | None = None, |
| 1332 | ) -> NoReturn: |
| 1333 | """Report internal error and exit. |
| 1334 | |
| 1335 | This optionally starts pdb or shows a traceback. |
| 1336 | """ |
| 1337 | stdout = stdout or sys.stdout |
| 1338 | stderr = stderr or sys.stderr |
| 1339 | # Dump out errors so far, they often provide a clue. |
| 1340 | # But catch unexpected errors rendering them. |
| 1341 | if errors: |
| 1342 | try: |
| 1343 | for msg in errors.new_messages(): |
| 1344 | print(msg) |
| 1345 | except Exception as e: |
| 1346 | print("Failed to dump errors:", repr(e), file=stderr) |
| 1347 | |
| 1348 | # Compute file:line prefix for official-looking error messages. |
| 1349 | if file: |
| 1350 | if line: |
| 1351 | prefix = f"{file}:{line}: " |
| 1352 | else: |
| 1353 | prefix = f"{file}: " |
| 1354 | else: |
| 1355 | prefix = "" |
| 1356 | |
| 1357 | # Print "INTERNAL ERROR" message. |
| 1358 | print( |
| 1359 | f"{prefix}error: INTERNAL ERROR --", |
| 1360 | "Please try using mypy master on GitHub:\n" |
| 1361 | "https://mypy.readthedocs.io/en/stable/common_issues.html" |
| 1362 | "#using-a-development-mypy-build", |
| 1363 | file=stderr, |
| 1364 | ) |
| 1365 | if options.show_traceback: |
| 1366 | print("Please report a bug at https://github.com/python/mypy/issues", file=stderr) |
| 1367 | else: |
| 1368 | print( |
| 1369 | "If this issue continues with mypy master, " |
| 1370 | "please report a bug at https://github.com/python/mypy/issues", |
| 1371 | file=stderr, |
| 1372 | ) |
| 1373 | print(f"version: {mypy_version}", file=stderr) |
| 1374 | |
| 1375 | # If requested, drop into pdb. This overrides show_tb. |
| 1376 | if options.pdb: |
| 1377 | print("Dropping into pdb", file=stderr) |
| 1378 | import pdb |
| 1379 | |
| 1380 | pdb.post_mortem(sys.exc_info()[2]) |
| 1381 |
no test coverage detected
searching dependent graphs…