[pypy-commit] pypy py3.5: Fix (without test, because there doesn't seem to be any test for the
arigo
pypy.commits at gmail.com
Thu Jan 12 13:26:43 EST 2017
Author: Armin Rigo <arigo at tunes.org>
Branch: py3.5
Changeset: r89524:24048a09826f
Date: 2017-01-12 18:26 +0100
http://bitbucket.org/pypy/pypy/changeset/24048a09826f/
Log: Fix (without test, because there doesn't seem to be any test for the
whole module; relying here on lib-
python/3/test/test_structmembers.py)
diff --git a/pypy/module/cpyext/structmember.py b/pypy/module/cpyext/structmember.py
--- a/pypy/module/cpyext/structmember.py
+++ b/pypy/module/cpyext/structmember.py
@@ -13,6 +13,13 @@
from pypy.module.cpyext.typeobjectdefs import PyMemberDef
from rpython.rlib.unroll import unrolling_iterable
+def convert_bool(space, w_obj):
+ if space.is_w(w_obj, space.w_False):
+ return False
+ if space.is_w(w_obj, space.w_True):
+ return True
+ raise oefmt(space.w_TypeError, "attribute value type must be bool")
+
integer_converters = unrolling_iterable([
(T_SHORT, rffi.SHORT, PyLong_AsLong),
(T_INT, rffi.INT, PyLong_AsLong),
@@ -22,7 +29,7 @@
(T_ULONG, rffi.ULONG, PyLong_AsUnsignedLong),
(T_BYTE, rffi.SIGNEDCHAR, PyLong_AsLong),
(T_UBYTE, rffi.UCHAR, PyLong_AsUnsignedLong),
- (T_BOOL, rffi.UCHAR, PyLong_AsLong),
+ (T_BOOL, rffi.UCHAR, convert_bool),
(T_FLOAT, rffi.FLOAT, PyFloat_AsDouble),
(T_DOUBLE, rffi.DOUBLE, PyFloat_AsDouble),
(T_LONGLONG, rffi.LONGLONG, PyLong_AsLongLong),
More information about the pypy-commit
mailing list