Author: Armin Rigo <[email protected]>
Branch: cpyext-gc-support-2
Changeset: r82227:9ead1cf8ed7e
Date: 2016-02-13 17:31 +0100
http://bitbucket.org/pypy/pypy/changeset/9ead1cf8ed7e/
Log: Avoid "if obj:" where obj is potentially a W_Root. Notably, if it is
a W_BoolObject then this complains.
diff --git a/pypy/module/cpyext/pyobject.py b/pypy/module/cpyext/pyobject.py
--- a/pypy/module/cpyext/pyobject.py
+++ b/pypy/module/cpyext/pyobject.py
@@ -260,18 +260,16 @@
"""Increment the reference counter of the PyObject and return it.
Can be called with either a PyObject or a W_Root.
"""
- if obj:
- if is_pyobj(obj):
- pyobj = rffi.cast(PyObject, obj)
- else:
- pyobj = as_pyobj(space, obj)
+ if is_pyobj(obj):
+ pyobj = rffi.cast(PyObject, obj)
+ else:
+ pyobj = as_pyobj(space, obj)
+ if pyobj:
assert pyobj.c_ob_refcnt > 0
pyobj.c_ob_refcnt += 1
if not is_pyobj(obj):
keepalive_until_here(obj)
- return pyobj
- else:
- return lltype.nullptr(PyObject.TO)
+ return pyobj
INTERPLEVEL_API['make_ref'] = make_ref
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit