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

import collections.abc explicitely #398

Merged
merged 2 commits into from Mar 4, 2019

Conversation

Projects
None yet
2 participants
@naums
Copy link
Contributor

naums commented Mar 3, 2019

When using wand I get the following error message:

Traceback (most recent call last):
  File "preprocess.py", line 6, in <module>
    from wand.image import Image
  File "/usr/lib/python3.7/site-packages/wand/image.py", line 18, in <module>
    from . import compat
  File "/usr/lib/python3.7/site-packages/wand/compat.py", line 25, in <module>
    abc = collections.abc if PY3 else collections
  File "/usr/lib/python3.7/collections/__init__.py", line 55, in __getattr__
    raise AttributeError(f'module {__name__!r} has no attribute {name!r}')
AttributeError: module 'collections' has no attribute 'abc'

My Python Versiin is 3.7.2. I found under [1] a statement, that abc was formerly in collections - I assume not anymore. Added a single import statement in compat.py, and the error was gone.

[1] https://docs.python.org/3/library/collections.abc.html

@emcconville

This comment has been minimized.

Copy link
Owner

emcconville commented Mar 4, 2019

Hey! The previous merge request #396 attempted this as well. If you just wrap the import statement with a try ... except ..., I would be happy to merge. Change should be backwards compatible after all :)

try:
    import collections.abc
except ImportError:
    pass

I haven't implemented this myself as the few distros that I have observed this AttributeError seems to resolve after clearing out pycache, but I haven't been able to confirm.

@naums

This comment has been minimized.

Copy link
Contributor Author

naums commented Mar 4, 2019

Thank you, done. You will however definitely want to try it on your (other) machines before merging. My Debian-machine had no problems at all, so maybe the problem lies on my end.

I haven't tried to clear the pycache, but this behaviour looks a bit strange to be caused by a dirty cache.

@emcconville

This comment has been minimized.

Copy link
Owner

emcconville commented Mar 4, 2019

I haven't tried to clear the pycache, but this behaviour looks a bit strange to be caused by a dirty cache.

I agree! Something changed w/ 3.7.2, and I haven't had time to review Python's release notes. It's also not consistent across distros, and that worries me. I'll merge this, and followup with a patch release after bit more investigating.

@emcconville emcconville merged commit dc7cac0 into emcconville:master Mar 4, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@emcconville emcconville added this to the 0.5.2 milestone Mar 22, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.