Skip to content
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

networkx 2.6: TypeError by passing None as closure to types.FunctionType() #38

Open
fumitoh opened this issue Mar 1, 2022 · 1 comment

Comments

@fumitoh
Copy link

fumitoh commented Mar 1, 2022

Hi, I tried to import networkx and encountered an error:

>>> import networkx as nx
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/fumito/nogil/nogil_build/lib/python3.9/site-packages/networkx/__init__.py", line 79, in <module>
    from networkx import algorithms
  File "/home/fumito/nogil/nogil_build/lib/python3.9/site-packages/networkx/algorithms/__init__.py", line 74, in <module>
    from networkx.algorithms import isomorphism
  File "/home/fumito/nogil/nogil_build/lib/python3.9/site-packages/networkx/algorithms/isomorphism/__init__.py", line 3, in <module>
    from networkx.algorithms.isomorphism.matchhelpers import *
  File "/home/fumito/nogil/nogil_build/lib/python3.9/site-packages/networkx/algorithms/isomorphism/matchhelpers.py", line 194, in <module>
    numerical_edge_match = copyfunc(numerical_node_match, "numerical_edge_match")
  File "/home/fumito/nogil/nogil_build/lib/python3.9/site-packages/networkx/algorithms/isomorphism/matchhelpers.py", line 22, in copyfunc
    return types.FunctionType(
TypeError: arg 5 (closure) must be tuple

numerical_node_match.__closure__ is None, so None is passed to copyfunc instead of a tuple. The original CPython doesn't rasie the error.

@colesbury
Copy link
Owner

Thanks for the bug report @fumitoh. networkx 2.6+ expose some issues with the nogil interpreter that aren't easy to resolve. In particular, there are some complicated cases involving modifying __kwdefaults__ and __code__ attributes on functions. I'll need to think a bit on how to handle those issues.

In the meantime, I think networkx 2.5.1 is compatible with nogil Python.

@colesbury colesbury changed the title TypeError by passing None as closure to types.FunctionType() networkx 2.6: TypeError by passing None as closure to types.FunctionType() Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants