Skip to content

Commit daf3e1f

Browse files
committed
Update HPy inlined files: b0fbdf73
1 parent 9baaf7c commit daf3e1f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1047
-81
lines changed

graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/version.h

Lines changed: 0 additions & 4 deletions
This file was deleted.

graalpython/com.oracle.graal.python.hpy.test/src/hpytest/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import pytest
22
from .support import ExtensionCompiler, DefaultExtensionTemplate,\
33
PythonSubprocessRunner, HPyDebugCapture, make_hpy_abi_fixture
4-
from hpy.debug.leakdetector import LeakDetector
54
from pathlib import Path
65

76
IS_VALGRIND_RUN = False
@@ -48,6 +47,7 @@ def leakdetector(hpy_abi):
4847
"""
4948
Automatically detect leaks when the hpy_abi == 'debug'
5049
"""
50+
from hpy.debug.leakdetector import LeakDetector
5151
if 'debug' in hpy_abi:
5252
with LeakDetector() as ld:
5353
yield ld

graalpython/com.oracle.graal.python.hpy.test/src/hpytest/debug/__init__.py

Whitespace-only changes.

graalpython/com.oracle.graal.python.hpy.test/src/hpytest/debug/test_charptr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
import pytest
3-
from test.support import SUPPORTS_SYS_EXECUTABLE, SUPPORTS_MEM_PROTECTION
3+
from ..support import SUPPORTS_SYS_EXECUTABLE, SUPPORTS_MEM_PROTECTION
44

55
# Tests detection of usage of char pointers associated with invalid already
66
# closed handles. For now, the debug mode does not provide any hook for this
@@ -293,4 +293,4 @@ def clear_raw_data_in_closed_handles():
293293
assert h.raw_data_size == -1
294294
finally:
295295
_debug.set_protected_raw_data_max_size(old_raw_data_max_size)
296-
_debug.set_closed_handles_queue_max_size(old_closed_handles_max_size)
296+
_debug.set_closed_handles_queue_max_size(old_closed_handles_max_size)

graalpython/com.oracle.graal.python.hpy.test/src/hpytest/debug/test_handles_invalid.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import pytest
2+
import sys
23
from hpy.debug.leakdetector import LeakDetector
3-
from test.support import SUPPORTS_SYS_EXECUTABLE, IS_PYTHON_DEBUG_BUILD
4-
from test.conftest import IS_VALGRIND_RUN
4+
from ..support import SUPPORTS_SYS_EXECUTABLE, IS_PYTHON_DEBUG_BUILD
5+
from ..conftest import IS_VALGRIND_RUN
56

67
@pytest.fixture
78
def hpy_abi():
89
with LeakDetector():
910
yield "debug"
1011

1112

13+
@pytest.mark.skipif(sys.implementation.name == 'pypy',
14+
reason="Cannot recover from use-after-close on pypy")
1215
def test_no_invalid_handle(compiler, hpy_debug_capture):
1316
# Basic sanity check that valid code does not trigger any error reports
1417
mod = compiler.make_module("""
@@ -33,6 +36,8 @@ def test_no_invalid_handle(compiler, hpy_debug_capture):
3336
assert hpy_debug_capture.invalid_handles_count == 0
3437

3538

39+
@pytest.mark.skipif(sys.implementation.name == 'pypy',
40+
reason="Cannot recover from use-after-close on pypy")
3641
def test_cant_use_closed_handle(compiler, hpy_debug_capture):
3742
mod = compiler.make_module("""
3843
HPyDef_METH(f, "f", HPyFunc_O, .doc="double close")
@@ -106,6 +111,8 @@ def test_cant_use_closed_handle(compiler, hpy_debug_capture):
106111
assert hpy_debug_capture.invalid_handles_count == 6
107112

108113

114+
@pytest.mark.skipif(sys.implementation.name == 'pypy',
115+
reason="Cannot recover from use-after-close on pypy")
109116
def test_keeping_and_reusing_argument_handle(compiler, hpy_debug_capture):
110117
mod = compiler.make_module("""
111118
HPy keep;
@@ -197,4 +204,4 @@ def test_invalid_handle_crashes_python_if_no_hook(compiler, python_subprocess, f
197204
""")
198205
result = python_subprocess.run(mod, "mod.f(42);")
199206
assert result.returncode == fatal_exit_code
200-
assert b"Invalid usage of already closed handle" in result.stderr
207+
assert b"Invalid usage of already closed handle" in result.stderr

graalpython/com.oracle.graal.python.hpy.test/src/hpytest/debug/test_misc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import pytest
2-
from test.support import SUPPORTS_SYS_EXECUTABLE, SUPPORTS_MEM_PROTECTION
2+
from ..support import SUPPORTS_SYS_EXECUTABLE, SUPPORTS_MEM_PROTECTION
33

44
@pytest.fixture
55
def hpy_abi():

graalpython/com.oracle.graal.python.hpy.test/src/hpytest/hpy_devel/__init__.py

Whitespace-only changes.

graalpython/com.oracle.graal.python.hpy.test/src/hpytest/hpy_devel/test_distutils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import py
1717
import pytest
1818

19-
from test.support import atomic_run, HPY_ROOT
19+
from ..support import atomic_run, HPY_ROOT
2020

2121
# ====== IMPORTANT DEVELOPMENT TIP =====
2222
# You can use py.test --reuse-venv to speed up local testing.

graalpython/com.oracle.graal.python.hpy.test/src/hpytest/support.py

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,19 @@ def make_hpy_abi_fixture(ABIs, class_fixture=False):
4949
class TestFoo(HPyTest):
5050
hpy_abi = make_hpy_abi_fixture('with hybrid', class_fixture=True)
5151
"""
52-
if ABIs == 'default':
53-
ABIs = ['cpython', 'universal', 'debug']
54-
elif ABIs == 'with hybrid':
55-
ABIs = ['cpython', 'hybrid', 'hybrid+debug']
56-
elif isinstance(ABIs, list):
52+
is_cpython = not hasattr(sys, "implementation") or sys.implementation.name == 'cpython'
53+
if isinstance(ABIs, list):
5754
pass
5855
else:
59-
raise ValueError("ABIs must be 'default', 'with hybrid' "
60-
"or a list of strings. Got: %s" % ABIs)
61-
56+
if ABIs == 'default':
57+
ABIs = ['universal', 'debug']
58+
elif ABIs == 'with hybrid':
59+
ABIs = ['hybrid', 'hybrid+debug']
60+
else:
61+
raise ValueError("ABIs must be 'default', 'with hybrid' "
62+
"or a list of strings. Got: %s" % ABIs)
63+
if is_cpython:
64+
ABIs.append('cpython')
6265
if class_fixture:
6366
@pytest.fixture(params=ABIs)
6467
def hpy_abi(self, request):
@@ -495,15 +498,6 @@ def supports_ordinary_make_module_imports(self):
495498
"""
496499
return True
497500

498-
def supports_refcounts(self):
499-
""" Returns True if the underlying Python implementation supports
500-
the vectorcall protocol.
501-
502-
By default, this returns True for Python version 3.8+ on all
503-
implementations.
504-
"""
505-
return sys.version_info >= (3, 8)
506-
507501

508502
class HPyDebugCapture:
509503
"""

graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_00_basic.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"""
99
from .support import HPyTest
1010
from hpy.devel.abitag import HPY_ABI_VERSION, HPY_ABI_VERSION_MINOR
11-
import shutil
1211

1312

1413
class TestBasic(HPyTest):
@@ -48,6 +47,7 @@ def test_abi_version_check(self):
4847
assert False, "Expected exception"
4948

5049
def test_abi_tag_check(self):
50+
import shutil
5151
if self.compiler.hpy_abi != 'universal':
5252
return
5353

@@ -262,6 +262,7 @@ def test_builtin_handles(self):
262262
case 20: h = ctx->h_MemoryViewType; break;
263263
case 21: h = ctx->h_SliceType; break;
264264
case 22: h = ctx->h_Builtins; break;
265+
case 23: h = ctx->h_DictType; break;
265266
case 2048: h = ctx->h_CapsuleType; break;
266267
default:
267268
HPyErr_SetString(ctx, ctx->h_ValueError, "invalid choice");
@@ -278,7 +279,7 @@ def test_builtin_handles(self):
278279
'<NULL>', None, False, True, ValueError, TypeError, IndexError,
279280
SystemError, object, type, bool, int, float, str, tuple, list,
280281
NotImplemented, Ellipsis, complex, bytes, memoryview, slice,
281-
builtins.__dict__
282+
builtins.__dict__, dict
282283
)
283284
for i, obj in enumerate(builtin_objs):
284285
if i == 0:
@@ -560,3 +561,20 @@ def test_leave_python(self):
560561
@INIT
561562
""")
562563
assert mod.f("abraka") == 3
564+
565+
def test_dup_null(self):
566+
mod = self.make_module("""
567+
HPyDef_METH(f, "f", HPyFunc_NOARGS)
568+
static HPy f_impl(HPyContext *ctx, HPy self)
569+
{
570+
HPy h = HPy_Dup(ctx, HPy_NULL);
571+
if (HPy_IsNull(h)) {
572+
return HPyLong_FromSize_t(ctx, 0);
573+
}
574+
HPy_Close(ctx, h);
575+
return HPyLong_FromSize_t(ctx, -1);
576+
}
577+
@EXPORT(f)
578+
@INIT
579+
""")
580+
assert mod.f() == 0

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy