Message182455
The common case for catching ImportError is exactly what ModuleNotFoundError represents. If people are already going to change their code to handle just this special case, I'd think having the subclass would be the better route. I find it simpler (both to update existing code and to read:
try:
from _thread import _local as local
except ModuleNotFoundError:
from _threading_local import local
vs.
try:
from _thread import _local as local
except ImportError as e:
if e.not_found:
from _threading_local import local
else:
raise
And for the broader case:
try:
import breakfast
except ModuleNotFoundError:
class breakfast:
spam = 0
eggs = 1
ham = 2
except ImportError as e:
log_some_message("uh oh: {}".format(e))
raise
vs.
try:
import breakfast
except ImportError as e:
if e.not_found:
class breakfast:
spam = 0
eggs = 1
ham = 2
else:
log_some_message("uh oh: {}".format(e))
raise |
|
Date |
User |
Action |
Args |
2013-02-20 00:25:08 | eric.snow | set | recipients:
+ eric.snow, barry, brett.cannon, pitrou, ezio.melotti, Arfrever, cvrebert, asvetlov, chris.jerdonek, serhiy.storchaka |
2013-02-20 00:25:08 | eric.snow | set | messageid: <1361319908.42.0.758692422717.issue15767@psf.upfronthosting.co.za> |
2013-02-20 00:25:08 | eric.snow | link | issue15767 messages |
2013-02-20 00:25:08 | eric.snow | create | |
|