Author: Alex Gaynor <alex.gay...@gmail.com> Branch: Changeset: r49326:fd3e370164e6 Date: 2011-11-11 11:24 -0500 http://bitbucket.org/pypy/pypy/changeset/fd3e370164e6/
Log: reorganize the conditions as armin suggested diff --git a/pypy/rpython/lltypesystem/ll2ctypes.py b/pypy/rpython/lltypesystem/ll2ctypes.py --- a/pypy/rpython/lltypesystem/ll2ctypes.py +++ b/pypy/rpython/lltypesystem/ll2ctypes.py @@ -1166,7 +1166,9 @@ TYPE1 = lltype.typeOf(value) cvalue = lltype2ctypes(value) cresulttype = get_ctypes_type(RESTYPE) - if isinstance(TYPE1, lltype.Ptr): + if RESTYPE == TYPE1: + return value + elif isinstance(TYPE1, lltype.Ptr): if isinstance(RESTYPE, lltype.Ptr): # shortcut: ptr->ptr cast cptr = ctypes.cast(cvalue, cresulttype) @@ -1179,8 +1181,6 @@ cvalue = ord(cvalue) # character -> integer elif hasattr(RESTYPE, "_type") and issubclass(RESTYPE._type, base_int): cvalue = int(cvalue) - elif RESTYPE is TYPE1: - return value if not isinstance(cvalue, (int, long, float)): raise NotImplementedError("casting %r to %r" % (TYPE1, RESTYPE)) _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit