Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Bug report
This code started failing thepylint check onbackports.zoneinfo recently:
@staticmethod@contextlib.contextmanagerdefpython_tzpath_context(value):path_var="PYTHONTZPATH"try:withOS_ENV_LOCK:old_env=os.environ.get(path_var,None)os.environ[path_var]=valueyieldfinally:ifold_envisNone:delos.environ[path_var]else:os.environ[path_var]=old_env# pragma: nocover
It's kind of a non-issue, but itis true that if an error is raised while acquiringOS_ENV_LOCK or when callingos.environ.get,old_env won't be set, which will raise aNameError. This is a kind of rare situation anyway, and it would probably only come up during a non-recoverable error, but we may as well fix it — if only so that people who use CPython as an example of "good code" will have an example of the right way to handle this sort of situation.
Probably this is trivial enough that we can skip an issue and news, but I'll just create one anyway 😛