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

Python's modulefinder package chokes on new versions of cherrypy - AttributeError: 'NoneType' object has no attribute 'is_package' #1986

Open
Melnorme1984 opened this issue Jan 19, 2023 · 0 comments

Comments

@Melnorme1984
Copy link

Melnorme1984 commented Jan 19, 2023

I work on a system that until now has used an old version of cherrypy (v8.9.1). We use Python's modulefinder package to resolve dependencies when building our executables. Currently we're upgrading the system to Python 3.11, which we found required us to upgrade to a new version of cherrypy (due to the use of getargspec). Unfortunately it seems modulefinder doesn't play nicely with v18.8.0 and presumably other newer versions.

  File "/usr/lib/python3.11/modulefinder.py", line 160, in load_file
    self.load_module(name, fp, pathname, stuff)
  File "/usr/lib/python3.11/modulefinder.py", line 349, in load_module
    self.scan_code(co, m)
  File "/usr/lib/python3.11/modulefinder.py", line 411, in scan_code
    self._safe_import_hook(name, m, fromlist, level=0)
  File "/usr/lib/python3.11/modulefinder.py", line 367, in _safe_import_hook
    self.import_hook(name, caller, level=level)
  File "/usr/lib/python3.11/modulefinder.py", line 165, in import_hook
    q, tail = self.find_head_package(parent, name)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/modulefinder.py", line 221, in find_head_package
    q = self.import_module(head, qname, parent)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/modulefinder.py", line 315, in import_module
    m = self.load_module(fqname, fp, pathname, stuff)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/modulefinder.py", line 328, in load_module
    m = self.load_package(fqname, pathname)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/modulefinder.py", line 460, in load_package
    self.load_module(fqname, fp, buf, stuff)
  File "/usr/lib/python3.11/modulefinder.py", line 349, in load_module
    self.scan_code(co, m)
  File "/usr/lib/python3.11/modulefinder.py", line 434, in scan_code
    self._safe_import_hook(name, m, fromlist, level=level)
  File "/usr/lib/python3.11/modulefinder.py", line 367, in _safe_import_hook
    self.import_hook(name, caller, level=level)
  File "/usr/lib/python3.11/modulefinder.py", line 165, in import_hook
    q, tail = self.find_head_package(parent, name)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/modulefinder.py", line 221, in find_head_package
    q = self.import_module(head, qname, parent)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/modulefinder.py", line 315, in import_module
    m = self.load_module(fqname, fp, pathname, stuff)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/modulefinder.py", line 349, in load_module
    self.scan_code(co, m)
  File "/usr/lib/python3.11/modulefinder.py", line 411, in scan_code
    self._safe_import_hook(name, m, fromlist, level=0)
  File "/usr/lib/python3.11/modulefinder.py", line 382, in _safe_import_hook
    self.import_hook(name, caller, [sub], level=level)
  File "/usr/lib/python3.11/modulefinder.py", line 170, in import_hook
    self.ensure_fromlist(m, fromlist)
  File "/usr/lib/python3.11/modulefinder.py", line 260, in ensure_fromlist
    submod = self.import_module(sub, subname, m)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/modulefinder.py", line 315, in import_module
    m = self.load_module(fqname, fp, pathname, stuff)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/modulefinder.py", line 349, in load_module
    self.scan_code(co, m)
  File "/usr/lib/python3.11/modulefinder.py", line 411, in scan_code
    self._safe_import_hook(name, m, fromlist, level=0)
  File "/usr/lib/python3.11/modulefinder.py", line 367, in _safe_import_hook
    self.import_hook(name, caller, level=level)
  File "/usr/lib/python3.11/modulefinder.py", line 165, in import_hook
    q, tail = self.find_head_package(parent, name)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/modulefinder.py", line 221, in find_head_package
    q = self.import_module(head, qname, parent)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/modulefinder.py", line 308, in import_module
    fp, pathname, stuff = self.find_module(partname,
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/modulefinder.py", line 489, in find_module
    return _find_module(name, path)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/modulefinder.py", line 69, in _find_module
    if spec.loader.is_package(name):
       ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'is_package'

Are we doing something wrong or is this a bug? There is a known issue in Python caused by namespace packages: https://bugs.python.org/issue40350

But I'm not sure if that's relevant here.

@Melnorme1984 Melnorme1984 changed the title modulefinder chokes on new versions of cherrypy Python's modulefinder package chokes on new versions of cherrypy - AttributeError: 'NoneType' object has no attribute 'is_package' Jan 19, 2023
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

1 participant