-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Importing glom
on Python3.12 fails
#336
Comments
I can only reproduce on python 3.12. It doesn't occur on 3.11 or earlier. This might be a Python bug, it's very strange. Here's a sample readout (python 3.12.4, pyinstrument 4.7.2). Reducing the interval makes the crash easier to reproduce. $ env312/bin/pyinstrument -i 0.0001 test.py
/Users/joerick/Desktop/glom/glom/core.py:506: RuntimeWarning: assigning None to unbound local 'k'
_BUILTIN_ID_NAME_MAP = dict([(id(v), k)
/Users/joerick/Desktop/glom/glom/core.py:506: RuntimeWarning: assigning None to unbound local 'v'
_BUILTIN_ID_NAME_MAP = dict([(id(v), k)
/Users/joerick/Desktop/glom/glom/mutation.py:211: RuntimeWarning: assigning None to unbound local 'v'
if not issubclass(v, tuple([t for t in _ALL_BUILTIN_TYPES
Traceback (most recent call last):
File "/Users/joerick/Desktop/glom/glom/core.py", line 2158, in register_op
handler = auto_func(t)
^^^^^^^^^^^^
File "/Users/joerick/Desktop/glom/glom/mutation.py", line 236, in _assign_autodiscover
if issubclass(type_obj, _UNASSIGNABLE_BASE_TYPES):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: issubclass() arg 2 must be a class, a tuple of classes, or a union
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/joerick/Desktop/glom/env312/bin/pyinstrument", line 8, in <module>
sys.exit(main())
^^^^^^
File "/Users/joerick/Desktop/glom/env312/lib/python3.12/site-packages/pyinstrument/__main__.py", line 382, in main
exec(code, globs, None)
File "<string>", line 1, in <module>
File "<frozen runpy>", line 286, in run_path
File "<frozen runpy>", line 98, in _run_module_code
File "<frozen runpy>", line 88, in _run_code
File "test.py", line 1, in <module>
import glom
File "/Users/joerick/Desktop/glom/glom/__init__.py", line 48, in <module>
from glom.mutation import Assign, Delete, assign, delete, PathDeleteError
File "/Users/joerick/Desktop/glom/glom/mutation.py", line 247, in <module>
register_op('assign', auto_func=_assign_autodiscover, exact=False)
File "/Users/joerick/Desktop/glom/glom/core.py", line 2437, in register_op
_DEFAULT_SCOPE[TargetRegistry].register_op(op_name, **kwargs)
File "/Users/joerick/Desktop/glom/glom/core.py", line 2160, in register_op
raise TypeError('error while determining support for operation'
TypeError: error while determining support for operation "assign" on target type: OrderedDict (got TypeError('issubclass() arg 2 must be a class, a tuple of classes, or a union'))
The warnings and crashes appear around these lines: And indeed it doesn't crash with cProfile or profile. But they do crash with pyinstrument, all the way back to v2.0 Something else caught my eye in one of these outputs. We get these errors 'Assigning None to unbound local x'. I once saw this:
That code was actually in Python itself! _inline_cache_entries = [
sum(_cache_format.get(opname[opcode], {}).values()) for opcode in range(256)
] The thing that has in common with the others is that this is a list comprehension at the module level. |
This issue from cpython appears relevant. I think the root cause is us calling LocalsToFast with the clear parameter. setting the clear parameters to 0 seems to solve the issue. But now I want to figure out if we need to call FastToLocals and LocalsToFast at all. We're not planning to change the locals anyway. |
…he trampoline `call_target`. Fix #336
Originally posted by @AvivSamet-Silk in #288 (comment)
The text was updated successfully, but these errors were encountered: