Armin Rigo avatar Armin Rigo committed e333a0a

os.major(), os.minor().

Comments (0)

Files changed (3)

pypy/module/posix/__init__.py

         interpleveldefs['ttyname'] = 'interp_posix.ttyname'
     if hasattr(os, 'getloadavg'):
         interpleveldefs['getloadavg'] = 'interp_posix.getloadavg'
+    if hasattr(os, 'major'):
+        interpleveldefs['major'] = 'interp_posix.major'
+    if hasattr(os, 'minor'):
+        interpleveldefs['minor'] = 'interp_posix.minor'
     if hasattr(os, 'mkfifo'):
         interpleveldefs['mkfifo'] = 'interp_posix.mkfifo'
     if hasattr(os, 'mknod'):

pypy/module/posix/interp_posix.py

                            space.wrap(load[2])])
 getloadavg.unwrap_spec = [ObjSpace]
 
+def major(space, device):
+    result = os.major(device)
+    return space.wrap(result)
+major.unwrap_spec = [ObjSpace, 'c_int']
+
+def minor(space, device):
+    result = os.minor(device)
+    return space.wrap(result)
+minor.unwrap_spec = [ObjSpace, 'c_int']
+
 def nice(space, inc):
     "Decrease the priority of process by inc and return the new priority."
     try:

pypy/module/posix/test/test_posix2.py

             cls.w_sysconf_result = space.wrap(os.sysconf(sysconf_name))
         cls.w_SIGABRT = space.wrap(signal.SIGABRT)
         cls.w_python = space.wrap(sys.executable)
+        if hasattr(os, 'major'):
+            cls.w_expected_major_12345 = space.wrap(os.major(12345))
+            cls.w_expected_minor_12345 = space.wrap(os.minor(12345))
 
     def setup_method(self, meth):
         if getattr(meth, 'need_sparse_files', False):
             assert type(l1) is float and l0 >= 0.0
             assert type(l2) is float and l0 >= 0.0
 
+    if hasattr(os, 'major'):
+        def test_major_minor(self):
+            os = self.posix
+            assert os.major(12345) == self.expected_major_12345
+            assert os.minor(12345) == self.expected_minor_12345
+
     if hasattr(os, 'fsync'):
         def test_fsync(self):
             os = self.posix
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.