Skip to content

[3.10] GH-102537: Handle check for PYTHONTZPATH failing in zoneinfo test (GH-102538) #102587

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

Merged
merged 1 commit into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Lib/test/test_zoneinfo/test_zoneinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1530,13 +1530,20 @@ class TzPathTest(TzPathUserMixin, ZoneInfoTestBase):
@contextlib.contextmanager
def python_tzpath_context(value):
path_var = "PYTHONTZPATH"
unset_env_sentinel = object()
old_env = unset_env_sentinel
try:
with OS_ENV_LOCK:
old_env = os.environ.get(path_var, None)
os.environ[path_var] = value
yield
finally:
if old_env is None:
if old_env is unset_env_sentinel:
# In this case, `old_env` was never retrieved from the
# environment for whatever reason, so there's no need to
# reset the environment TZPATH.
pass
elif old_env is None:
del os.environ[path_var]
else:
os.environ[path_var] = old_env # pragma: nocover
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Adjust the error handling strategy in
``test_zoneinfo.TzPathTest.python_tzpath_context``. Patch by Paul Ganssle.