[pypy-commit] pypy more-rposix: Give a better name to the list of os.WEXITSTATUS macros

amauryfa noreply at buildbot.pypy.org
Fri Dec 5 22:15:44 CET 2014


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: more-rposix
Changeset: r74842:0edb78d84f6a
Date: 2014-11-11 21:16 +0100
http://bitbucket.org/pypy/pypy/changeset/0edb78d84f6a/

Log:	Give a better name to the list of os.WEXITSTATUS macros

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
@@ -1,4 +1,5 @@
 from pypy.interpreter.mixedmodule import MixedModule
+from rpython.rlib import rposix
 
 import os
 exec 'import %s as posix' % os.name
@@ -171,9 +172,7 @@
     if hasattr(os, 'chroot'):
         interpleveldefs['chroot'] = 'interp_posix.chroot'
 
-    for name in ['WCOREDUMP', 'WIFCONTINUED', 'WIFSTOPPED',
-                 'WIFSIGNALED', 'WIFEXITED',
-                 'WEXITSTATUS', 'WSTOPSIG', 'WTERMSIG']:
+    for name in rposix.WAIT_MACROS:
         if hasattr(os, name):
             interpleveldefs[name] = 'interp_posix.' + name
 
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
@@ -1214,9 +1214,7 @@
     WSTAR.func_name = name
     return WSTAR
 
-for name in ['WCOREDUMP', 'WIFCONTINUED', 'WIFSTOPPED',
-             'WIFSIGNALED', 'WIFEXITED',
-             'WEXITSTATUS', 'WSTOPSIG', 'WTERMSIG']:
+for name in rposix.WAIT_MACROS:
     if hasattr(os, name):
         func = declare_new_w_star(name)
         globals()[name] = func
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
@@ -7,6 +7,7 @@
 from pypy.tool.pytest.objspace import gettestobjspace
 from pypy.conftest import pypydir
 from rpython.translator.c.test.test_extfunc import need_sparse_files
+from rpython.rlib import rposix
 import os
 import py
 import sys
@@ -575,9 +576,7 @@
         raises(TypeError, "os.utime('xxx', 3)")
         raises(OSError, "os.utime('somefilewhichihopewouldneverappearhere', None)")
 
-    for name in ['WCOREDUMP', 'WIFCONTINUED', 'WIFSTOPPED',
-                 'WIFSIGNALED', 'WIFEXITED',
-                 'WEXITSTATUS', 'WSTOPSIG', 'WTERMSIG']:
+    for name in rposix.WAIT_MACROS:
         if hasattr(os, name):
             values = [0, 1, 127, 128, 255]
             code = py.code.Source("""
diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -765,9 +765,10 @@
         else:
             return bool(c_func(status))
 
-for name in ['WCOREDUMP', 'WIFCONTINUED', 'WIFSTOPPED',
-             'WIFSIGNALED', 'WIFEXITED',
-             'WEXITSTATUS', 'WSTOPSIG', 'WTERMSIG']:
+WAIT_MACROS = ['WCOREDUMP', 'WIFCONTINUED', 'WIFSTOPPED',
+               'WIFSIGNALED', 'WIFEXITED',
+               'WEXITSTATUS', 'WSTOPSIG', 'WTERMSIG']
+for name in WAIT_MACROS:
     _make_waitmacro(name)
 
 #___________________________________________________________________
diff --git a/rpython/rtyper/module/test/test_posix.py b/rpython/rtyper/module/test/test_posix.py
--- a/rpython/rtyper/module/test/test_posix.py
+++ b/rpython/rtyper/module/test/test_posix.py
@@ -210,10 +210,8 @@
             assert self.interpret(f, []) == 1
 
     def test_os_wstar(self):
-        from rpython.rtyper.module.ll_os import RegisterOs
-        for name in ['WCOREDUMP', 'WIFCONTINUED', 'WIFSTOPPED',
-                     'WIFSIGNALED', 'WIFEXITED',
-                     'WEXITSTATUS', 'WSTOPSIG', 'WTERMSIG']:
+        from rpython.rlib import rposix
+        for name in rposix.WAIT_MACROS:
             if not hasattr(os, name):
                 continue
             def fun(s):


More information about the pypy-commit mailing list