mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Fix SF # 631066, running regrtest in user mode fails
Try to write to TESTFN, if that fails, try TESTFN in /tmp If that fails, print a warning and go on. Will backport.
This commit is contained in:
parent
034c749ff4
commit
26a1eefd0f
1 changed files with 21 additions and 1 deletions
|
@ -97,7 +97,27 @@ elif os.name != 'riscos':
|
|||
TESTFN_ENCODING="mbcs"
|
||||
else:
|
||||
TESTFN = 'test'
|
||||
del os
|
||||
|
||||
# Make sure we can write to TESTFN, try in /tmp if we can't
|
||||
fp = None
|
||||
try:
|
||||
fp = open(TESTFN, 'w+')
|
||||
except IOError:
|
||||
TMP_TESTFN = os.path.join('/tmp', TESTFN)
|
||||
try:
|
||||
fp = open(TMP_TESTFN, 'w+')
|
||||
TESTFN = TMP_TESTFN
|
||||
del TMP_TESTFN
|
||||
except IOError:
|
||||
print ('WARNING: tests will fail, unable to write to: %s or %s' %
|
||||
(TESTFN, TMP_TESTFN))
|
||||
if fp is not None:
|
||||
fp.close()
|
||||
try:
|
||||
os.unlink(TESTFN)
|
||||
except:
|
||||
pass
|
||||
del os, fp
|
||||
|
||||
from os import unlink
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue