Skip to content

Commit

Permalink
fixes from pypy
Browse files Browse the repository at this point in the history
  • Loading branch information
mattip committed Jan 22, 2025
1 parent 79fb330 commit bda29a2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion hpy/devel/include/hpy/hpydef.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extern "C" {
#include "hpy/autogen_hpyslot.h"
#include "hpy/cpy_types.h"

typedef void* (*HPyCFunction)();
typedef void* (*HPyCFunction)(void);
typedef void (*HPyFunc_Capsule_Destructor)(const char *name, void *pointer, void *context);

/**
Expand Down
10 changes: 8 additions & 2 deletions hpy/devel/include/hpy/hpymodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,23 @@ typedef struct {
*/
#define HPy_MODINIT(ext_name, mod_def) \
HPy_EXPORTED_FUNC uint32_t \
get_required_hpy_major_version_##ext_name() \
get_required_hpy_major_version_##ext_name(void); \
uint32_t \
get_required_hpy_major_version_##ext_name(void) \
{ \
return HPY_ABI_VERSION; \
} \
HPy_EXPORTED_FUNC uint32_t \
get_required_hpy_minor_version_##ext_name() \
get_required_hpy_minor_version_##ext_name(void); \
uint32_t \
get_required_hpy_minor_version_##ext_name(void) \
{ \
return HPY_ABI_VERSION_MINOR; \
} \
_HPy_CTX_MODIFIER HPyContext *_ctx_for_trampolines; \
HPy_EXPORTED_FUNC void \
HPyInitGlobalContext_##ext_name(HPyContext *ctx); \
void \
HPyInitGlobalContext_##ext_name(HPyContext *ctx) \
{ \
_ctx_for_trampolines = ctx; \
Expand Down
6 changes: 6 additions & 0 deletions test/debug/test_handles_invalid.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ def hpy_abi():
yield "debug"


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


@pytest.mark.skipif(sys.implementation.name == 'pypy',
reason="Cannot recover from use-after-close on pypy")
def test_cant_use_closed_handle(compiler, hpy_debug_capture):
mod = compiler.make_module("""
HPyDef_METH(f, "f", HPyFunc_O, .doc="double close")
Expand Down Expand Up @@ -106,6 +110,8 @@ def test_cant_use_closed_handle(compiler, hpy_debug_capture):
assert hpy_debug_capture.invalid_handles_count == 6


@pytest.mark.skipif(sys.implementation.name == 'pypy',
reason="Cannot recover from use-after-close on pypy")
def test_keeping_and_reusing_argument_handle(compiler, hpy_debug_capture):
mod = compiler.make_module("""
HPy keep;
Expand Down

0 comments on commit bda29a2

Please sign in to comment.