[pypy-commit] pypy stdlib-2.7.8: merged upstream
alex_gaynor
noreply at buildbot.pypy.org
Sat Aug 23 17:14:38 CEST 2014
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: stdlib-2.7.8
Changeset: r72998:b4818b82a1da
Date: 2014-08-23 08:14 -0700
http://bitbucket.org/pypy/pypy/changeset/b4818b82a1da/
Log: merged upstream
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -8,7 +8,7 @@
compute_unique_id, specialize)
from rpython.rlib.signature import signature
from rpython.rlib.rarithmetic import r_uint, SHRT_MIN, SHRT_MAX, \
- INT_MIN, INT_MAX, UINT_MAX
+ INT_MIN, INT_MAX, UINT_MAX, USHRT_MAX
from pypy.interpreter.executioncontext import (ExecutionContext, ActionFlag,
UserDelAction)
@@ -1646,6 +1646,16 @@
"signed short integer is greater than maximum")
return value
+ def c_ushort_w(self, w_obj):
+ value = self.int_w(w_obj)
+ if value < 0:
+ raise oefmt(self.w_OverflowError,
+ "can't convert negative value to C unsigned short")
+ elif value > USHRT_MAX:
+ raise oefmt(self.w_OverflowError,
+ "Python int too large for C unsigned short")
+ return value
+
def truncatedint_w(self, w_obj, allow_conversion=True):
# Like space.gateway_int_w(), but return the integer truncated
# instead of raising OverflowError. For obscure cases only.
diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py
--- a/pypy/interpreter/gateway.py
+++ b/pypy/interpreter/gateway.py
@@ -164,6 +164,9 @@
def visit_c_short(self, el, app_sig):
self.checked_space_method(el, app_sig)
+ def visit_c_ushort(self, el, app_sig):
+ self.checked_space_method(el, app_sig)
+
def visit_truncatedint_w(self, el, app_sig):
self.checked_space_method(el, app_sig)
@@ -288,6 +291,9 @@
def visit_c_short(self, typ):
self.run_args.append("space.c_short_w(%s)" % (self.scopenext(),))
+ def visit_c_ushort(self, typ):
+ self.run_args.append("space.c_ushort_w(%s)" % (self.scopenext(),))
+
def visit_truncatedint_w(self, typ):
self.run_args.append("space.truncatedint_w(%s)" % (self.scopenext(),))
@@ -431,6 +437,9 @@
def visit_c_short(self, typ):
self.unwrap.append("space.c_short_w(%s)" % (self.nextarg(),))
+ def visit_c_ushort(self, typ):
+ self.unwrap.append("space.c_ushort_w(%s)" % (self.nextarg(),))
+
def visit_truncatedint_w(self, typ):
self.unwrap.append("space.truncatedint_w(%s)" % (self.nextarg(),))
diff --git a/pypy/module/select/interp_select.py b/pypy/module/select/interp_select.py
--- a/pypy/module/select/interp_select.py
+++ b/pypy/module/select/interp_select.py
@@ -1,13 +1,11 @@
import errno
from rpython.rlib import _rsocket_rffi as _c, rpoll
-from rpython.rlib.rarithmetic import USHRT_MAX
from rpython.rtyper.lltypesystem import lltype, rffi
from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.error import OperationError, oefmt, wrap_oserror
-from pypy.interpreter.gateway import (
- Unwrapper, WrappedDefault, interp2app, unwrap_spec)
+from pypy.interpreter.gateway import WrappedDefault, interp2app, unwrap_spec
from pypy.interpreter.typedef import TypeDef
defaultevents = rpoll.POLLIN | rpoll.POLLOUT | rpoll.POLLPRI
@@ -26,30 +24,17 @@
return Poll()
-class UShortUnwrapper(Unwrapper):
-
- def unwrap(self, space, w_value):
- value = space.int_w(w_value)
- if value < 0:
- raise oefmt(space.w_OverflowError,
- "can't convert negative value to C unsigned short")
- if value > USHRT_MAX:
- raise oefmt(space.w_OverflowError,
- "Python int too large for C unsigned short")
- return value
-
-
class Poll(W_Root):
def __init__(self):
self.fddict = {}
self.running = False
- @unwrap_spec(events=UShortUnwrapper)
+ @unwrap_spec(events="c_ushort")
def register(self, space, w_fd, events=defaultevents):
fd = space.c_filedescriptor_w(w_fd)
self.fddict[fd] = events
- @unwrap_spec(events=UShortUnwrapper)
+ @unwrap_spec(events="c_ushort")
def modify(self, space, w_fd, events):
fd = space.c_filedescriptor_w(w_fd)
if fd not in self.fddict:
More information about the pypy-commit
mailing list