Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit64bde50

Browse files
authored
GH-102537: Handle check for PYTHONTZPATH failing in zoneinfo test (GH-102538)
It is possible but unlikely for the `python_tzpath_context` function to fail between the start of the `try` block and the point where `os.environ.get` succeeds, in which case `old_env` will be undefined. In this case, we want to take no action.Practically speaking this will really only happen in an error condition anyway, so it doesn't really matter, but we should probably do it right anyway.
1 parent53dceb5 commit64bde50

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

‎Lib/test/test_zoneinfo/test_zoneinfo.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1543,13 +1543,20 @@ class TzPathTest(TzPathUserMixin, ZoneInfoTestBase):
15431543
@contextlib.contextmanager
15441544
defpython_tzpath_context(value):
15451545
path_var="PYTHONTZPATH"
1546+
unset_env_sentinel=object()
1547+
old_env=unset_env_sentinel
15461548
try:
15471549
withOS_ENV_LOCK:
15481550
old_env=os.environ.get(path_var,None)
15491551
os.environ[path_var]=value
15501552
yield
15511553
finally:
1552-
ifold_envisNone:
1554+
ifold_envisunset_env_sentinel:
1555+
# In this case, `old_env` was never retrieved from the
1556+
# environment for whatever reason, so there's no need to
1557+
# reset the environment TZPATH.
1558+
pass
1559+
elifold_envisNone:
15531560
delos.environ[path_var]
15541561
else:
15551562
os.environ[path_var]=old_env# pragma: nocover
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Adjust the error handling strategy in
2+
``test_zoneinfo.TzPathTest.python_tzpath_context``. Patch by Paul Ganssle.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp