diff -r f36d8ba4eeef Lib/tempfile.py --- a/Lib/tempfile.py Sat Feb 09 12:21:52 2013 +0200 +++ b/Lib/tempfile.py Sat Feb 09 16:31:54 2013 +0200 @@ -31,6 +31,7 @@ import sys as _sys import io as _io import os as _os +import errno as _errno from random import Random as _Random try: @@ -181,7 +182,9 @@ 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 @@ -214,7 +217,8 @@ 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. @@ -301,7 +305,8 @@ 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 @@ -330,7 +335,8 @@ if not _exists(file): return file - raise FileExistsError("No usable temporary filename found") + raise FileExistsError(_errno.EEXIST, + "No usable temporary filename found") class _TemporaryFileWrapper: