bpo-30108: Fix test_site setUpModule() (#1460)
Oops, I forgot that PermissionError was introduced in Python 3.3!
Replace PermissionError with OSError and check on errno.
diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py
index 3ba5dca..9569135 100644
--- a/Lib/test/test_site.py
+++ b/Lib/test/test_site.py
@@ -8,6 +8,7 @@
from test.test_support import run_unittest, TESTFN, EnvironmentVarGuard
from test.test_support import captured_output
import __builtin__
+import errno
import os
import sys
import re
@@ -38,9 +39,12 @@
os.makedirs(site.USER_SITE)
# modify sys.path: will be restored by tearDownModule()
site.addsitedir(site.USER_SITE)
- except PermissionError as exc:
- raise unittest.SkipTest('unable to create user site directory (%r): %s'
- % (site.USER_SITE, exc))
+ except OSError as exc:
+ if exc.errno in (errno.EACCES, errno.EPERM):
+ raise unittest.SkipTest('unable to create user site directory (%r): %s'
+ % (site.USER_SITE, exc))
+ else:
+ raise
def tearDownModule():