offlineimap3 icon indicating copy to clipboard operation
offlineimap3 copied to clipboard

fix: "module importlib has no attribute 'machinery'"

Open tucksaun opened this issue 1 year ago • 4 comments

This PR

Since the merge of https://github.com/OfflineIMAP/offlineimap3/pull/190, the following errors happens:

ERROR: module 'importlib' has no attribute 'machinery'
ERROR: Exceptions occurred during the run!
ERROR: AttributeError: module 'importlib' has no attribute 'machinery'

This commit should fix this by importing the required package.

  • [X] I've read the DCO.
  • [X] I've read the Coding Guidelines
  • [X] The relevant informations about the changes stands in the commit message, not here in the message of the pull request.
  • [X] Code changes follow the style of the files they change.
  • [X] Code is tested (tested with my backup scripts).

References

Additional information

I'm no Python expert but it seems that importlib.machinery is only introduced in Python 3.3 so in order to maintain potential compatibility I added the import in the if clause just before it gets used. Let me know if you prefer if to be at the top of the file

tucksaun avatar Sep 03 '24 07:09 tucksaun

Are you using a pre-3.3 version of Python? I'm not getting this error in either the Python 3.10 provided by the distro I use or the Python 3.12 I got through Conda. Maybe it's time to bump the Python requirement (after all, imaplib2 3.6 requires Python 3.6+ and the latest imaplib2 code in their Git repo requires Python 3.10+); I try my best to make sure my contributions will work in older versions of Python, but the code would be so much less messy without having to make concessions for unreasonably old versions.

keithbowes avatar Sep 05 '24 17:09 keithbowes

I have this error with the latest official python Docker images (3.12.5 as of writing) but I also had it with previous versions (I stopped my investigation after a couple of earlier versions, 3.9 IIRC)

tucksaun avatar Sep 05 '24 18:09 tucksaun

Can confirm this error with Python 3.11.9.

r7l avatar Sep 21 '24 17:09 r7l

I also needed this patch with Python 3.11.11 on guix system. It worked without it when the package was still using 3.10.

league avatar May 18 '25 14:05 league

Same here with:

$ python --version
Python 3.11.14

michael-o avatar Oct 25 '25 21:10 michael-o