Index: Lib/tempfile.py =================================================================== --- Lib/tempfile.py (revision 77795) +++ Lib/tempfile.py (working copy) @@ -316,7 +316,7 @@ file = _os.path.join(dir, prefix + name + suffix) try: _os.mkdir(file, 0700) - return file + return _os.path.abspath(file) except OSError, e: if e.errno == _errno.EEXIST: continue # try again Index: Lib/test/test_tempfile.py =================================================================== --- Lib/test/test_tempfile.py (revision 77795) +++ Lib/test/test_tempfile.py (working copy) @@ -51,6 +51,8 @@ nsuf = nbase[len(nbase)-len(suf):] # check for equality of the absolute paths! + self.assertTrue(os.path.isabs(name), + "path '%s' is not an absolute path" % (name)) self.assertEqual(os.path.abspath(ndir), os.path.abspath(dir), "file '%s' not in directory '%s'" % (name, dir)) self.assertEqual(npre, pre, @@ -103,7 +105,7 @@ def test_get_six_char_str(self): # _RandomNameSequence returns a six-character string s = self.r.next() - self.nameCheck(s, '', '', '') + self.nameCheck(os.path.abspath("./" + s), '', '', '') def test_many(self): # _RandomNameSequence returns no duplicate strings (stochastic) @@ -112,7 +114,7 @@ r = self.r for i in xrange(TEST_FILES): s = r.next() - self.nameCheck(s, '', '', '') + self.nameCheck(os.path.abspath("./" + s), '', '', '') self.assertNotIn(s, dict) dict[s] = 1 @@ -486,6 +488,17 @@ finally: os.rmdir(dir) + def test_abs_path(self): + #mkdtemp verifies existence of absolute paths when given relative path + try: + cwd = os.getcwd() + os.chdir(tempfile.gettempdir()) + name = self.do_create(dir=".") + finally: + os.chdir(cwd) + + os.rmdir(name) + test_classes.append(test_mkdtemp)