[pypy-svn] r46266 - pypy/branch/pypy-more-rtti-inprogress/rpython/module

arigo at codespeak.net arigo at codespeak.net
Mon Sep 3 12:38:56 CEST 2007


Author: arigo
Date: Mon Sep  3 12:38:56 2007
New Revision: 46266

Modified:
   pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py
Log:
Make the RPython interface to os.mkdir() always take a mode argument,
which we just ignore on Windows (CPython's os.mkdir() behaves like that too).


Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py	(original)
+++ pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py	Mon Sep  3 12:38:56 2007
@@ -716,21 +716,21 @@
     @registering(os.mkdir)
     def register_os_mkdir(self):
         if os.name == 'nt':
-            ARG2 = []         # no 'mode' argument on Windows
-            arg2 = []
+            ARG2 = []         # no 'mode' argument on Windows - just ignored
         else:
             ARG2 = [rffi.MODE_T]
-            arg2 = [int]
         os_mkdir = self.llexternal('mkdir', [rffi.CCHARP]+ARG2, rffi.INT)
+        IGNORE_MODE = len(ARG2) == 0
 
-        def mkdir_llimpl(pathname, *opt_mode):
-            if opt_mode:
-                opt_mode = (opt_mode[0],)
-            res = os_mkdir(pathname, *opt_mode)
+        def mkdir_llimpl(pathname, mode):
+            if IGNORE_MODE:
+                res = os_mkdir(pathname)
+            else:
+                res = os_mkdir(pathname, mode)
             if res < 0:
                 raise OSError(rffi.get_errno(), "os_mkdir failed")
 
-        return extdef([str]+arg2, s_None, llimpl=mkdir_llimpl,
+        return extdef([str, int], s_None, llimpl=mkdir_llimpl,
                       export_name="ll_os.ll_os_mkdir")
 
     @registering(os.rmdir)


More information about the pypy-svn mailing list