This repository was archived by the owner on Oct 23, 2023. It is now read-only.
This repository was archived by the owner on Oct 23, 2023. It is now read-only.
Please don't import eventlet even if it's available #854
Open
Description
This code has two problems:
try:
import eventlet
try:
from eventlet.green import urllib2 as eventlet_urllib2
except ImportError:
from eventlet.green.urllib import request as eventlet_urllib2
has_eventlet = True
except:
has_eventlet = False
- Bare
except:
is evil, please catch a specific exception, ImportError in this case. - I am trying to get rid of eventlet in my code base, and so I have an assertion in my code:
assert 'eventlet' not in sys.modules
. Unconditionally importing eventlet makes it fail that assertion. Instead, could you please get the module only if it's already imported?if 'eventlet' in sys.modules: stuff
.