diff options
author | Ronan Lamy <ronan.lamy@gmail.com> | 2021-03-12 18:41:50 +0000 |
---|---|---|
committer | Ronan Lamy <ronan.lamy@gmail.com> | 2021-03-12 18:41:50 +0000 |
commit | 7c5d5d6e4389a82627ecd6aef25849dc23c93adc (patch) | |
tree | 5e4d00a0d6458c0d7a63cda79567f0a631a2b218 | |
parent | Add the other .supports_foo() helpers (diff) | |
download | pypy-7c5d5d6e4389a82627ecd6aef25849dc23c93adc.tar.gz pypy-7c5d5d6e4389a82627ecd6aef25849dc23c93adc.tar.bz2 pypy-7c5d5d6e4389a82627ecd6aef25849dc23c93adc.zip |
Implement HPyTuple_Check
-rw-r--r-- | pypy/module/_hpy_universal/interp_tuple.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/pypy/module/_hpy_universal/interp_tuple.py b/pypy/module/_hpy_universal/interp_tuple.py index bb38411545..f9560cbb44 100644 --- a/pypy/module/_hpy_universal/interp_tuple.py +++ b/pypy/module/_hpy_universal/interp_tuple.py @@ -8,3 +8,11 @@ def HPyTuple_FromArray(space, ctx, items, n): items_w[i] = handles.deref(space, items[i]) w_result = space.newtuple(items_w) return handles.new(space, w_result) + +@API.func("int HPyTuple_Check(HPyContext ctx, HPy h)", error_value='CANNOT_FAIL') +def HPyTuple_Check(space, ctx, h): + w_obj = handles.deref(space, h) + w_obj_type = space.type(w_obj) + res = (space.is_w(w_obj_type, space.w_tuple) or + space.issubtype_w(w_obj_type, space.w_tuple)) + return API.int(res) |