Kaydet (Commit) d4e3bb3d authored tarafından Martin v. Löwis's avatar Martin v. Löwis

Port access, chmod, parts of getcwdu, mkdir, and utime to direct Win32 API.

üst ce5933f5
...@@ -327,6 +327,10 @@ def mkdtemp(suffix="", prefix=template, dir=None): ...@@ -327,6 +327,10 @@ def mkdtemp(suffix="", prefix=template, dir=None):
try: try:
_os.mkdir(file, 0700) _os.mkdir(file, 0700)
return file return file
except WindowsError, e:
if e.errno == 183: # ERROR_ALREADY_EXISTS
continue # try again
raise
except OSError, e: except OSError, e:
if e.errno == _errno.EEXIST: if e.errno == _errno.EEXIST:
continue # try again continue # try again
......
...@@ -375,6 +375,18 @@ class Win32ErrorTests(unittest.TestCase): ...@@ -375,6 +375,18 @@ class Win32ErrorTests(unittest.TestCase):
def test_chdir(self): def test_chdir(self):
self.assertRaises(WindowsError, os.chdir, test_support.TESTFN) self.assertRaises(WindowsError, os.chdir, test_support.TESTFN)
def test_mkdir(self):
self.assertRaises(WindowsError, os.chdir, test_support.TESTFN)
def test_utime(self):
self.assertRaises(WindowsError, os.utime, test_support.TESTFN, None)
def test_access(self):
self.assertRaises(WindowsError, os.utime, test_support.TESTFN, 0)
def test_chmod(self):
self.assertRaises(WindowsError, os.utime, test_support.TESTFN, 0)
if sys.platform != 'win32': if sys.platform != 'win32':
class Win32ErrorTests(unittest.TestCase): class Win32ErrorTests(unittest.TestCase):
pass pass
......
...@@ -67,8 +67,8 @@ Core and builtins ...@@ -67,8 +67,8 @@ Core and builtins
Extension Modules Extension Modules
----------------- -----------------
- Use Win32 API to implement os.{chdir,rename,rmdir,remove}. As a result, - Use Win32 API to implement os.{access,chdir,chmod,mkdir,remove,rename,rmdir,utime}.
these functions now raise WindowsError instead of OSError. As a result, these functions now raise WindowsError instead of OSError.
- Calling Tk_Init twice is refused if the first call failed as that - Calling Tk_Init twice is refused if the first call failed as that
may deadlock. may deadlock.
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment