Skip to content

Commit 431d827

Browse files
committed
fix possible KeyError
1 parent f2e08aa commit 431d827

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Lib/test/test_webbrowser.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,8 @@ def setUp(self):
326326
# Ensure that 'BROWSER' is not set to 'open' or something else.
327327
# See: https://github.com/python/cpython/issues/131254.
328328
env = self.enterContext(os_helper.EnvironmentVarGuard())
329-
env.unset("BROWSER")
329+
if "BROWSER" in env:
330+
env.unset("BROWSER")
330331

331332
support.patch(self, os, "popen", self.mock_popen)
332333
self.browser = webbrowser.MacOSXOSAScript("default")

0 commit comments

Comments
 (0)