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

>=0.25.0 with Python 2.7: Importing eventlet.green.urllib breaks urlparse from the future library #681

Open
jdominguez-wish opened this issue Jan 19, 2021 · 4 comments
Labels
platform-python2 Related only to deprecated Python2.7

Comments

@jdominguez-wish
Copy link

jdominguez-wish commented Jan 19, 2021

Environment: Docker container built from python:2.7-slim-buster (Debian variant). Also verified on my own computer running Ubuntu 20.04.1 LTS
eventlet version: >= 0.25.0 (I verified that the bug does not occur with ==0.24.1 but does occur with ==0.25.0. I also verified that it occurs with the latest master.)
Output from uname -a: Linux c9efdf963b14 5.4.0-59-generic #65-Ubuntu SMP Thu Dec 10 12:01:51 UTC 2020 x86_64 GNU/Linux
Python version: 2.7.18
pip freeze:

dnspython==1.16.0
eventlet==0.30.0
future==0.18.2
greenlet==1.0.0
monotonic==1.5
six==1.15.0

I have searched the previous issues and found no mention of this issue.

Description: In Python 2, we use a library which is designed to work across both Python 2 and Python 3 for now. It uses future.standard_library.install_aliases to do this. However, when using this library in tandem with eventlet, and importing eventlet.green.urllib, the aliases no longer work and the library fails with an ImportError.

Steps to reproduce: Run the following MWE:

from future.standard_library import install_aliases
install_aliases()
import eventlet.green.urllib
from urllib.parse import urlparse # ImportError: No module named parse

Please let me know if more information or clarification is required! I tried to investigate this as thoroughly as I could but it's certainly possible that I missed something. Also, I saw that Python 2.7 support is deprecated (understandably so), so if this bug is deemed not worth fixing, it might be worth adding a notice to the affected versions.

@temoto
Copy link
Member

temoto commented Jan 22, 2021

It's correct, there is no urllib.parse in Python2.

@temoto temoto added the platform-python2 Related only to deprecated Python2.7 label Jan 22, 2021
@jdominguez-wish
Copy link
Author

Hi, thanks for your reply! I understand that usually that is the case. However, install_aliases is supposed to add an alias to urlparse so that one can write code that works on both Python 2 and Python 3. For example, the following modified snippet runs fine in Python 2 (I should have mentioned this above, sorry):

from future.standard_library import install_aliases
install_aliases()
#import eventlet.green.urllib
from urllib.parse import urlparse

@temoto
Copy link
Member

temoto commented Jan 26, 2021

Yes, it seems like a bug with Eventlet. I don't have time to dig deeper, in part because we've deprecated Python2 support.

My best suggestion is import urllib from six, it's known to work with eventlet patching.

@jdominguez-wish
Copy link
Author

I see, thanks for taking the time to read the issue nonetheless. I think we'll stick with the older version of eventlet mentioned above for now (given that the relevant code is contained inside a dependency), until (hopefully) upgrading to Python 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform-python2 Related only to deprecated Python2.7
Projects
None yet
Development

No branches or pull requests

2 participants