Bug report
Bug description:
When using a simple trace function, importing ssl fails with an AttributeError.
The same import works normally without sys.settrace().
Tested on:
Python 3.16.0a0 (heads/main:24e5a55ccb0, Aug 28 2026, 02:25:05) [MSC v.1951 64 bit (AMD64)] on win32
Python 3.14.5 (tags/v3.14.5:5607950, May 10 2026, 10:43:50) [MSC v.1944 64 bit (AMD64)] on win32
Python 3.13.14 (tags/v3.13.14:fd17997, Jun 10 2026, 13:03:48) [MSC v.1944 64 bit (AMD64)] on win32
import sys
def trace(*args):
a = print
a(args)
return a
sys.settrace(trace)
import ssl
Traceback:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
import ssl
File "D:\my\pythons\cpython\Lib\ssl.py", line 415, in <module>
class Purpose(_ASN1Object, _Enum):
...<3 lines>...
CLIENT_AUTH = '1.3.6.1.5.5.7.3.2'
File "D:\my\pythons\cpython\Lib\enum.py", line 574, in __new__
enum_class = super().__new__(metacls, cls, bases, classdict, **kwds)
File "D:\my\pythons\cpython\Lib\enum.py", line 257, in __set_name__
enum_member = enum_class._new_member_(enum_class, *args)
File "D:\my\pythons\cpython\Lib\ssl.py", line 400, in __new__
return super().__new__(cls, *_txt2obj(oid, name=False))
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<string>", line 1, in <lambda>
File "D:\my\pythons\cpython\Lib\enum.py", line 1296, in __str__
return "%s.%s" % (self.__class__.__name__, self._name_, )
^^^^^^^^^^^
AttributeError: 'Purpose' object has no attribute '_name_'. Did you mean '.name' instead of '._name_'?
CPython versions tested on:
CPython main branch, 3.14, 3.13
Operating systems tested on:
Windows
Bug report
Bug description:
When using a simple trace function, importing ssl fails with an AttributeError.
The same import works normally without sys.settrace().
Tested on:
Python 3.16.0a0 (heads/main:24e5a55ccb0, Aug 28 2026, 02:25:05) [MSC v.1951 64 bit (AMD64)] on win32
Python 3.14.5 (tags/v3.14.5:5607950, May 10 2026, 10:43:50) [MSC v.1944 64 bit (AMD64)] on win32
Python 3.13.14 (tags/v3.13.14:fd17997, Jun 10 2026, 13:03:48) [MSC v.1944 64 bit (AMD64)] on win32
Traceback:
CPython versions tested on:
CPython main branch, 3.14, 3.13
Operating systems tested on:
Windows