pythontraceback

How to disable the caret (^) characters in the Python stacktrace?


I have a script for doing test readouts that worked fine with Python 3.9 but now we upgraded to Python 3.12 we have those carets that break the script. So the easiest way would be disabling it.

Is there a way to disable the carets (^^^^^^^^^^^^^^^^^^^^) in the Python stacktrace?

ERROR: test_email (tests.test_emails.EmailTestCase.test_email)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/my-project/email/tests/test_emails.py", line 72, in test_email
    self.assertNotEquals(self.email.id, self.email_id)
    ^^^^^^^^^^^^^^^^^^^^

Solution

  • You can run Python with the -X no_debug_ranges command-line option, or set the PYTHONNODEBUGRANGES environment variable (to any nonempty string) before running your program, to disable these indicators.