summaryrefslogtreecommitdiffstats
path: root/Lib/tempfile.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-02-09 20:27:23 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-02-09 20:27:23 (GMT)
commit26cab565423a830701667555980232baeca07580 (patch)
tree2bbccd21ea340ea78158efefe4eae980d0f963a0 /Lib/tempfile.py
parent31c3cd2fb8aa7d587f1c1317052f48f45de97094 (diff)
parent7451a72e2ba8939215324387e36285725632e637 (diff)
downloadcpython-26cab565423a830701667555980232baeca07580.zip
cpython-26cab565423a830701667555980232baeca07580.tar.gz
cpython-26cab565423a830701667555980232baeca07580.tar.bz2
Issue #17169: Restore errno in tempfile exceptions.
Diffstat (limited to 'Lib/tempfile.py')
-rw-r--r--Lib/tempfile.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/Lib/tempfile.py b/Lib/tempfile.py
index 8f8743c4..908533f 100644
--- a/Lib/tempfile.py
+++ b/Lib/tempfile.py
@@ -31,6 +31,7 @@ import warnings as _warnings
import sys as _sys
import io as _io
import os as _os
+import errno as _errno
from random import Random as _Random
try:
@@ -183,7 +184,9 @@ def _get_default_tempdir():
pass
except OSError:
break # no point trying more names in this directory
- raise FileNotFoundError("No usable temporary directory found in %s" % dirlist)
+ raise FileNotFoundError(_errno.ENOENT,
+ "No usable temporary directory found in %s" %
+ dirlist)
_name_sequence = None
@@ -216,7 +219,8 @@ def _mkstemp_inner(dir, pre, suf, flags):
except FileExistsError:
continue # try again
- raise FileExistsError("No usable temporary file name found")
+ raise FileExistsError(_errno.EEXIST,
+ "No usable temporary file name found")
# User visible interfaces.
@@ -303,7 +307,8 @@ def mkdtemp(suffix="", prefix=template, dir=None):
except FileExistsError:
continue # try again
- raise FileExistsError("No usable temporary directory name found")
+ raise FileExistsError(_errno.EEXIST,
+ "No usable temporary directory name found")
def mktemp(suffix="", prefix=template, dir=None):
"""User-callable function to return a unique temporary file name. The
@@ -332,7 +337,8 @@ def mktemp(suffix="", prefix=template, dir=None):
if not _exists(file):
return file
- raise FileExistsError("No usable temporary filename found")
+ raise FileExistsError(_errno.EEXIST,
+ "No usable temporary filename found")
class _TemporaryFileWrapper: