Fedora Account System
Red Hat Associate
Red Hat Customer
Python 3.13 introduced the new interactive interpreter colors (https://docs.python.org/3/using/cmdline.html#controlling-color). It seems IDLE3 is not yet prepared to handle these and emitshard to read plain text with ANSI color controls in it instead. Reproducible: Always Steps to Reproduce: 1. Open IDLE3 2. try to run: os.path (just an example, any other error that triggers use of interpreter colors will also do) 3. observe the mal-formatted error message Actual Results: Traceback (most recent call last): File e[35m"/usr/lib64/python3.13/idlelib/run.py"e[0m, line e[35m590e[0m, in e[35mruncodee[0m e[31mexece[0me[1;31m(code, self.locals)e[0m e[31m~~~~e[0me[1;31m^^^^^^^^^^^^^^^^^^^e[0m File e[35m"<pyshell#0>"e[0m, line e[35m1e[0m, in e[35m<module>e[0m e[1;35mNameErrore[0m: e[35mname 'os' is not defined. Did you forget to import 'os'?e[0m Expected Results: Traceback (most recent call last): File "/usr/lib64/python3.13/idlelib/run.py", line 590, in runcode exec(code, self.locals) ~~~~^^^^^^^^^^^^^^^^^^^ File "<pyshell#0>", line 1, in <module> NameError: name 'os' is not defined. Did you forget to import 'os'? A simple fix is to pass PYTHON_COLORS=0 to idle through its .desktop file.
I can reproduce this with Python 3.13. It is fixed in Python 3.14.0a1.
When I build Python 3.13.0 from git source, I cannot reproduce this :/
When I build Python 3.13.0 from our RPM, I can still reproduce this.
IDLE has a different code path depending on sys.excepthook. On Fedora, ABRT installs a special hook in sys.excepthook. (A) ABRT case: * IDLE replaces sys.stderr with a idlelib.run.StdOutputFile object at startup. * _colorize.can_colorize() returns True because StdOutputFile.isatty() always return True. (B) Default case: * IDLE replaces sys.stderr with io.StringIO() to call the "excepthook". * _colorize.can_colorize() returns False. ABRT comes python3-abrt-addon package, main files: * /usr/lib/python3.13/site-packages/abrt3.pth * /usr/lib/python3.13/site-packages/abrt_exception_handler3.py I'm not sure why IDLE StdOutputFile pretends to be a TTY, whereas it's not.
I reported the issue to Python upstream: https://github.com/python/cpython/issues/127060
> I reported the issue to Python upstream: https://github.com/python/cpython/issues/127060 I fixed the issue. The 3.13 fix: https://github.com/python/cpython/commit/f8b4e20137b5c5d1e99cbf6c8f35f7041785b4c1. The fix will be part of the next Python 3.13 release (3.13.2, scheduled at 2025-02-04).
> A simple fix is to pass PYTHON_COLORS=0 to idle through its .desktop file. Another workaround is to set TERM environment variable to "dumb" when running IDLE.
This was fixed in https://github.com/python/cpython/pull/128052 -- it did not make it into 3.13.1. We can backport it if needed.