[pypy-commit] pypy stdlib-2.7.3: INET6Address: Do like CPython and raise OverflowError when a negative value is passed for flowinfo.
amauryfa
noreply at buildbot.pypy.org
Thu Jun 14 23:15:10 CEST 2012
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: stdlib-2.7.3
Changeset: r55672:81bb5cfe7180
Date: 2012-06-14 23:13 +0200
http://bitbucket.org/pypy/pypy/changeset/81bb5cfe7180/
Log: INET6Address: Do like CPython and raise OverflowError when a
negative value is passed for flowinfo.
diff --git a/pypy/rlib/rsocket.py b/pypy/rlib/rsocket.py
--- a/pypy/rlib/rsocket.py
+++ b/pypy/rlib/rsocket.py
@@ -408,13 +408,14 @@
host = space.str_w(pieces_w[0])
port = space.int_w(pieces_w[1])
port = Address.make_ushort_port(space, port)
- if len(pieces_w) > 2: flowinfo = space.uint_w(pieces_w[2])
+ if len(pieces_w) > 2: flowinfo = space.int_w(pieces_w[2])
else: flowinfo = 0
if len(pieces_w) > 3: scope_id = space.uint_w(pieces_w[3])
else: scope_id = 0
if flowinfo < 0 or flowinfo > 0xfffff:
raise OperationError(space.w_OverflowError, space.wrap(
"flowinfo must be 0-1048575."))
+ flowinfo = rffi.cast(lltype.Unsigned, flowinfo)
return INET6Address(host, port, flowinfo, scope_id)
from_object = staticmethod(from_object)
@@ -427,13 +428,14 @@
"to 4, not %d" % len(pieces_w))
port = space.int_w(pieces_w[1])
port = self.make_ushort_port(space, port)
- if len(pieces_w) > 2: flowinfo = space.uint_w(pieces_w[2])
+ if len(pieces_w) > 2: flowinfo = space.int_w(pieces_w[2])
else: flowinfo = 0
if len(pieces_w) > 3: scope_id = space.uint_w(pieces_w[3])
else: scope_id = 0
if flowinfo < 0 or flowinfo > 0xfffff:
raise OperationError(space.w_OverflowError, space.wrap(
"flowinfo must be 0-1048575."))
+ flowinfo = rffi.cast(lltype.Unsigned, flowinfo)
a = self.lock(_c.sockaddr_in6)
rffi.setintfield(a, 'c_sin6_port', htons(port))
rffi.setintfield(a, 'c_sin6_flowinfo', htonl(flowinfo))
More information about the pypy-commit
mailing list