pytoolz / toolz

A functional standard library for Python.
http://toolz.readthedocs.org/
Other
4.71k stars 263 forks source link

import issues with py311 #528

Closed tacaswell closed 2 years ago

tacaswell commented 2 years ago

There appears to be more issues with toolz + py311 + circular imports:

$ ipython
Python 3.11.0a4+ (heads/main:bebaa95fd0, Feb  1 2022, 14:37:27) [GCC 11.1.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.30.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import tlz

In [2]: tlz.__version__
Out[2]: '0.11.2+3.gf3ac821'

In [3]: import tlz.curried
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-e8157afb3962> in <module>
----> 1 import tlz.curried

~/.pybuild/bleeding/lib/python3.11/importlib/_bootstrap.py in _find_and_load(name, import_)

~/.pybuild/bleeding/lib/python3.11/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_)

~/.pybuild/bleeding/lib/python3.11/importlib/_bootstrap.py in _load_unlocked(spec)

~/.virtualenvs/bleeding/lib/python3.11/site-packages/tlz/_build_tlz.py in exec_module(self, module)
     83                 package, dot, submodules = v.__name__.partition('.')
     84                 module_name = ''.join(['tlz', dot, submodules])
---> 85                 submodule = import_module(module_name)
     86                 module.__dict__[k] = submodule
     87 

~/.pybuild/bleeding/lib/python3.11/importlib/__init__.py in import_module(name, package)
    124                 break
    125             level += 1
--> 126     return _bootstrap._gcd_import(name[level:], package, level)
    127 
    128 

~/.pybuild/bleeding/lib/python3.11/importlib/_bootstrap.py in _gcd_import(name, package, level)

~/.pybuild/bleeding/lib/python3.11/importlib/_bootstrap.py in _find_and_load(name, import_)

~/.pybuild/bleeding/lib/python3.11/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_)

AttributeError: 'TlzSpec' object has no attribute '_uninitialized_submodules'

In [4]: 
eriknw commented 2 years ago

There sure is! I actually poked around with this a few days ago in PR https://github.com/pytoolz/toolz/pull/527:

https://github.com/pytoolz/toolz/runs/4986061605?check_suite_focus=true

I haven't dug any deeper yet, but it might be nice if we can upstream changes so we no longer break.

tacaswell commented 2 years ago

Ah, sorry I did not search hard enough before opening this issue.

eriknw commented 2 years ago

ha, no worries, thanks for the issue!

opoplawski commented 2 years ago

Any progress here? Fedora is updating to 3.11 and tests are failing:

___________________________________ test_tlz ___________________________________
    def test_tlz():
        import tlz
        tlz.curry
        tlz.functoolz.curry
        assert tlz.__package__ == 'tlz'
        assert tlz.__name__ == 'tlz'
>       import tlz.curried
toolz/tests/test_tlz.py:10: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
<frozen importlib._bootstrap>:1178: in _find_and_load
    ???
<frozen importlib._bootstrap>:1149: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:690: in _load_unlocked
    ???
../../BUILDROOT/python-toolz-0.11.2-4.fc37.noarch/usr/lib/python3.11/site-packages/tlz/_build_tlz.py:85: in exec_module
    submodule = import_module(module_name)
/usr/lib64/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1206: in _gcd_import
    ???
<frozen importlib._bootstrap>:1178: in _find_and_load
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
name = 'tlz.curried.operator', import_ = <function _gcd_import at 0x3ff952cfd80>
>   ???
E   AttributeError: 'TlzSpec' object has no attribute '_uninitialized_submodules'
<frozen importlib._bootstrap>:1147: AttributeError
eriknw commented 2 years ago

My bad. Got sick. Better now. I'll get a fix in ASAP. May take a couple of days. Thanks for the nudge.

tacaswell commented 2 years ago

Thank you @eriknw ! Looking at that diff I am not sure I would have ever gotten there.....

opoplawski commented 2 years ago

Thank you!