Author: Joannah Nanjekye <nanjekyejoan...@gmail.com>
Branch: get/setpriority
Changeset: r90382:e22cb19efefa
Date: 2017-01-17 17:29 +0300
http://bitbucket.org/pypy/pypy/changeset/e22cb19efefa/

Log:    error handling

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
@@ -1846,10 +1846,11 @@
     
     Get program scheduling priority.
     """
-    try:
-        returned_priority = rposix.c_getpriority(program, identifier)
-    except OSError as e:
-        raise wrap_oserror(space, e)
+    error = None
+    returned_priority = 
rposix.handle_posix_error('getpriority',rposix.c_getpriority(program, 
identifier))
+    error = rposix.get_saved_errno()
+    if error == 0:
+        raise OSError(error, "getpriority failed")
     return space.wrap(returned_priority)
 
 @unwrap_spec(program=int, identifier=int, priority=int)
@@ -1858,10 +1859,11 @@
     
     Set program scheduling priority.
     """
-    try:
-        rposix.c_setpriority(program, identifier, priority)
-    except OSError as e:
-        raise wrap_oserror(space, e)
+    rposix.c_setpriority(program, identifier, priority)
+    error = rposix.get_saved_errno()
+    if error == -1:
+        raise OSError(error, "setpriority failed")
+        
 
 def declare_new_w_star(name):
     if name in ('WEXITSTATUS', 'WSTOPSIG', 'WTERMSIG'):
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
@@ -11,7 +11,7 @@
 from rpython.rlib import rposix
 
 USEMODULES = ['binascii', 'posix', 'signal', 'struct', 'time']
-# py3k os.open uses subprocess, requiring the following per platform
+# py3k  os.open uses subprocess, requiring the following per platform
 if os.name != 'nt':
     USEMODULES += ['fcntl', 'select', '_posixsubprocess']
 else:
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to