[pypy-svn] pypy default: os.major(), os.minor().
arigo
commits-noreply at bitbucket.org
Sat Jan 29 16:11:03 CET 2011
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r41446:e333a0abe296
Date: 2011-01-29 15:55 +0100
http://bitbucket.org/pypy/pypy/changeset/e333a0abe296/
Log: os.major(), os.minor().
diff --git a/pypy/module/posix/test/test_posix2.py b/pypy/module/posix/test/test_posix2.py
--- a/pypy/module/posix/test/test_posix2.py
+++ b/pypy/module/posix/test/test_posix2.py
@@ -68,6 +68,9 @@
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):
@@ -562,6 +565,12 @@
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
diff --git a/pypy/module/posix/interp_posix.py b/pypy/module/posix/interp_posix.py
--- a/pypy/module/posix/interp_posix.py
+++ b/pypy/module/posix/interp_posix.py
@@ -1107,6 +1107,16 @@
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:
diff --git a/pypy/module/posix/__init__.py b/pypy/module/posix/__init__.py
--- a/pypy/module/posix/__init__.py
+++ b/pypy/module/posix/__init__.py
@@ -124,6 +124,10 @@
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'):
More information about the Pypy-commit
mailing list