diff --git a/hpy/devel/include/common/autogen_impl.h b/hpy/devel/include/common/autogen_impl.h index 5d3d52325..17ae3dfc5 100644 --- a/hpy/devel/include/common/autogen_impl.h +++ b/hpy/devel/include/common/autogen_impl.h @@ -273,6 +273,11 @@ HPyAPI_STORAGE void _HPy_IMPL_NAME(Err_SetString)(HPyContext ctx, HPy h_type, co PyErr_SetString(_h2py(h_type), message); } +HPyAPI_STORAGE void _HPy_IMPL_NAME(Err_SetObject)(HPyContext ctx, HPy h_type, HPy h_value) +{ + PyErr_SetObject(_h2py(h_type), _h2py(h_value)); +} + HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Err_NoMemory)(HPyContext ctx) { return _py2h(PyErr_NoMemory()); diff --git a/hpy/devel/include/cpython/hpy.h b/hpy/devel/include/cpython/hpy.h index 7b098e9b5..8f97c4be1 100644 --- a/hpy/devel/include/cpython/hpy.h +++ b/hpy/devel/include/cpython/hpy.h @@ -45,15 +45,77 @@ typedef Py_hash_t HPy_hash_t; // this should maybe autogenerated from public_api.h typedef struct _HPyContext_s { + /* Constants */ HPy h_None; HPy h_True; HPy h_False; + /* Exceptions */ + HPy h_BaseException; HPy h_Exception; + HPy h_StopAsyncIteration; + HPy h_StopIteration; + HPy h_GeneratorExit; + HPy h_ArithmeticError; + HPy h_LookupError; + HPy h_AssertionError; + HPy h_AttributeError; + HPy h_BufferError; + HPy h_EOFError; + HPy h_FloatingPointError; + HPy h_OSError; + HPy h_ImportError; + HPy h_ModuleNotFoundError; HPy h_IndexError; + HPy h_KeyError; + HPy h_KeyboardInterrupt; + HPy h_MemoryError; + HPy h_NameError; HPy h_OverflowError; + HPy h_RuntimeError; + HPy h_RecursionError; + HPy h_NotImplementedError; + HPy h_SyntaxError; + HPy h_IndentationError; + HPy h_TabError; + HPy h_ReferenceError; HPy h_SystemError; + HPy h_SystemExit; HPy h_TypeError; + HPy h_UnboundLocalError; + HPy h_UnicodeError; + HPy h_UnicodeEncodeError; + HPy h_UnicodeDecodeError; + HPy h_UnicodeTranslateError; HPy h_ValueError; + HPy h_ZeroDivisionError; + HPy h_BlockingIOError; + HPy h_BrokenPipeError; + HPy h_ChildProcessError; + HPy h_ConnectionError; + HPy h_ConnectionAbortedError; + HPy h_ConnectionRefusedError; + HPy h_ConnectionResetError; + HPy h_FileExistsError; + HPy h_FileNotFoundError; + HPy h_InterruptedError; + HPy h_IsADirectoryError; + HPy h_NotADirectoryError; + HPy h_PermissionError; + HPy h_ProcessLookupError; + HPy h_TimeoutError; + /* Warnings */ + HPy h_Warning; + HPy h_UserWarning; + HPy h_DeprecationWarning; + HPy h_PendingDeprecationWarning; + HPy h_SyntaxWarning; + HPy h_RuntimeWarning; + HPy h_FutureWarning; + HPy h_ImportWarning; + HPy h_UnicodeWarning; + HPy h_BytesWarning; + HPy h_ResourceWarning; + /* Types */ HPy h_BaseObjectType; HPy h_TypeType; HPy h_LongType; @@ -81,15 +143,77 @@ _HPyGetContext(void) { if (HPy_IsNull(ctx->h_None)) { // XXX: we need to find a better way to check whether the ctx is // initialized or not + /* Constants */ ctx->h_None = _py2h(Py_None); ctx->h_True = _py2h(Py_True); ctx->h_False = _py2h(Py_False); + /* Exceptions */ + ctx->h_BaseException = _py2h(PyExc_BaseException); ctx->h_Exception = _py2h(PyExc_Exception); + ctx->h_StopAsyncIteration = _py2h(PyExc_StopAsyncIteration); + ctx->h_StopIteration = _py2h(PyExc_StopIteration); + ctx->h_GeneratorExit = _py2h(PyExc_GeneratorExit); + ctx->h_ArithmeticError = _py2h(PyExc_ArithmeticError); + ctx->h_LookupError = _py2h(PyExc_LookupError); + ctx->h_AssertionError = _py2h(PyExc_AssertionError); + ctx->h_AttributeError = _py2h(PyExc_AttributeError); + ctx->h_BufferError = _py2h(PyExc_BufferError); + ctx->h_EOFError = _py2h(PyExc_EOFError); + ctx->h_FloatingPointError = _py2h(PyExc_FloatingPointError); + ctx->h_OSError = _py2h(PyExc_OSError); + ctx->h_ImportError = _py2h(PyExc_ImportError); + ctx->h_ModuleNotFoundError = _py2h(PyExc_ModuleNotFoundError); ctx->h_IndexError = _py2h(PyExc_IndexError); + ctx->h_KeyError = _py2h(PyExc_KeyError); + ctx->h_KeyboardInterrupt = _py2h(PyExc_KeyboardInterrupt); + ctx->h_MemoryError = _py2h(PyExc_MemoryError); + ctx->h_NameError = _py2h(PyExc_NameError); ctx->h_OverflowError = _py2h(PyExc_OverflowError); + ctx->h_RuntimeError = _py2h(PyExc_RuntimeError); + ctx->h_RecursionError = _py2h(PyExc_RecursionError); + ctx->h_NotImplementedError = _py2h(PyExc_NotImplementedError); + ctx->h_SyntaxError = _py2h(PyExc_SyntaxError); + ctx->h_IndentationError = _py2h(PyExc_IndentationError); + ctx->h_TabError = _py2h(PyExc_TabError); + ctx->h_ReferenceError = _py2h(PyExc_ReferenceError); ctx->h_SystemError = _py2h(PyExc_SystemError); + ctx->h_SystemExit = _py2h(PyExc_SystemExit); ctx->h_TypeError = _py2h(PyExc_TypeError); + ctx->h_UnboundLocalError = _py2h(PyExc_UnboundLocalError); + ctx->h_UnicodeError = _py2h(PyExc_UnicodeError); + ctx->h_UnicodeEncodeError = _py2h(PyExc_UnicodeEncodeError); + ctx->h_UnicodeDecodeError = _py2h(PyExc_UnicodeDecodeError); + ctx->h_UnicodeTranslateError = _py2h(PyExc_UnicodeTranslateError); ctx->h_ValueError = _py2h(PyExc_ValueError); + ctx->h_ZeroDivisionError = _py2h(PyExc_ZeroDivisionError); + ctx->h_BlockingIOError = _py2h(PyExc_BlockingIOError); + ctx->h_BrokenPipeError = _py2h(PyExc_BrokenPipeError); + ctx->h_ChildProcessError = _py2h(PyExc_ChildProcessError); + ctx->h_ConnectionError = _py2h(PyExc_ConnectionError); + ctx->h_ConnectionAbortedError = _py2h(PyExc_ConnectionAbortedError); + ctx->h_ConnectionRefusedError = _py2h(PyExc_ConnectionRefusedError); + ctx->h_ConnectionResetError = _py2h(PyExc_ConnectionResetError); + ctx->h_FileExistsError = _py2h(PyExc_FileExistsError); + ctx->h_FileNotFoundError = _py2h(PyExc_FileNotFoundError); + ctx->h_InterruptedError = _py2h(PyExc_InterruptedError); + ctx->h_IsADirectoryError = _py2h(PyExc_IsADirectoryError); + ctx->h_NotADirectoryError = _py2h(PyExc_NotADirectoryError); + ctx->h_PermissionError = _py2h(PyExc_PermissionError); + ctx->h_ProcessLookupError = _py2h(PyExc_ProcessLookupError); + ctx->h_TimeoutError = _py2h(PyExc_TimeoutError); + /* Warnings */ + ctx->h_Warning = _py2h(PyExc_Warning); + ctx->h_UserWarning = _py2h(PyExc_UserWarning); + ctx->h_DeprecationWarning = _py2h(PyExc_DeprecationWarning); + ctx->h_PendingDeprecationWarning = _py2h(PyExc_PendingDeprecationWarning); + ctx->h_SyntaxWarning = _py2h(PyExc_SyntaxWarning); + ctx->h_RuntimeWarning = _py2h(PyExc_RuntimeWarning); + ctx->h_FutureWarning = _py2h(PyExc_FutureWarning); + ctx->h_ImportWarning = _py2h(PyExc_ImportWarning); + ctx->h_UnicodeWarning = _py2h(PyExc_UnicodeWarning); + ctx->h_BytesWarning = _py2h(PyExc_BytesWarning); + ctx->h_ResourceWarning = _py2h(PyExc_ResourceWarning); + /* Types */ ctx->h_BaseObjectType = _py2h((PyObject *)&PyBaseObject_Type); ctx->h_TypeType = _py2h((PyObject *)&PyType_Type); ctx->h_LongType = _py2h((PyObject *)&PyLong_Type); diff --git a/hpy/devel/include/universal/autogen_ctx.h b/hpy/devel/include/universal/autogen_ctx.h index 231cfc4d8..044c93ffd 100644 --- a/hpy/devel/include/universal/autogen_ctx.h +++ b/hpy/devel/include/universal/autogen_ctx.h @@ -13,12 +13,70 @@ struct _HPyContext_s { HPy h_None; HPy h_True; HPy h_False; + HPy h_BaseException; HPy h_Exception; + HPy h_StopAsyncIteration; + HPy h_StopIteration; + HPy h_GeneratorExit; + HPy h_ArithmeticError; + HPy h_LookupError; + HPy h_AssertionError; + HPy h_AttributeError; + HPy h_BufferError; + HPy h_EOFError; + HPy h_FloatingPointError; + HPy h_OSError; + HPy h_ImportError; + HPy h_ModuleNotFoundError; HPy h_IndexError; + HPy h_KeyError; + HPy h_KeyboardInterrupt; + HPy h_MemoryError; + HPy h_NameError; HPy h_OverflowError; + HPy h_RuntimeError; + HPy h_RecursionError; + HPy h_NotImplementedError; + HPy h_SyntaxError; + HPy h_IndentationError; + HPy h_TabError; + HPy h_ReferenceError; HPy h_SystemError; + HPy h_SystemExit; HPy h_TypeError; + HPy h_UnboundLocalError; + HPy h_UnicodeError; + HPy h_UnicodeEncodeError; + HPy h_UnicodeDecodeError; + HPy h_UnicodeTranslateError; HPy h_ValueError; + HPy h_ZeroDivisionError; + HPy h_BlockingIOError; + HPy h_BrokenPipeError; + HPy h_ChildProcessError; + HPy h_ConnectionError; + HPy h_ConnectionAbortedError; + HPy h_ConnectionRefusedError; + HPy h_ConnectionResetError; + HPy h_FileExistsError; + HPy h_FileNotFoundError; + HPy h_InterruptedError; + HPy h_IsADirectoryError; + HPy h_NotADirectoryError; + HPy h_PermissionError; + HPy h_ProcessLookupError; + HPy h_TimeoutError; + HPy h_Warning; + HPy h_UserWarning; + HPy h_DeprecationWarning; + HPy h_PendingDeprecationWarning; + HPy h_SyntaxWarning; + HPy h_RuntimeWarning; + HPy h_FutureWarning; + HPy h_ImportWarning; + HPy h_UnicodeWarning; + HPy h_BytesWarning; + HPy h_ResourceWarning; HPy h_BaseObjectType; HPy h_TypeType; HPy h_LongType; @@ -81,6 +139,7 @@ struct _HPyContext_s { HPy (*ctx_InPlaceXor)(HPyContext ctx, HPy h1, HPy h2); HPy (*ctx_InPlaceOr)(HPyContext ctx, HPy h1, HPy h2); void (*ctx_Err_SetString)(HPyContext ctx, HPy h_type, const char *message); + void (*ctx_Err_SetObject)(HPyContext ctx, HPy h_type, HPy h_value); int (*ctx_Err_Occurred)(HPyContext ctx); HPy (*ctx_Err_NoMemory)(HPyContext ctx); void (*ctx_Err_Clear)(HPyContext ctx); diff --git a/hpy/devel/include/universal/autogen_trampolines.h b/hpy/devel/include/universal/autogen_trampolines.h index 3c909030f..1bf0dbaef 100644 --- a/hpy/devel/include/universal/autogen_trampolines.h +++ b/hpy/devel/include/universal/autogen_trampolines.h @@ -232,6 +232,10 @@ static inline void HPyErr_SetString(HPyContext ctx, HPy h_type, const char *mess ctx->ctx_Err_SetString ( ctx, h_type, message ); } +static inline void HPyErr_SetObject(HPyContext ctx, HPy h_type, HPy h_value) { + ctx->ctx_Err_SetObject ( ctx, h_type, h_value ); +} + static inline int HPyErr_Occurred(HPyContext ctx) { return ctx->ctx_Err_Occurred ( ctx ); } diff --git a/hpy/tools/autogen/parse.py b/hpy/tools/autogen/parse.py index 0491576bf..388506963 100644 --- a/hpy/tools/autogen/parse.py +++ b/hpy/tools/autogen/parse.py @@ -152,6 +152,7 @@ def _visit_hpyslot_slot(self, node): 'HPy_SetItem_i': None, 'HPy_SetItem_s': None, 'HPy_Length': 'PyObject_Length', + 'HPy_Call': 'PyObject_Call', '_HPy_Cast': None, 'HPy_FromPyObject': None, 'HPy_AsPyObject': None, diff --git a/hpy/tools/autogen/public_api.h b/hpy/tools/autogen/public_api.h index 9c653f255..e3ff8e552 100644 --- a/hpy/tools/autogen/public_api.h +++ b/hpy/tools/autogen/public_api.h @@ -18,15 +18,82 @@ typedef int HPyTracker; /* HPy public API */ +/* Constants */ HPy h_None; HPy h_True; HPy h_False; + +/* Exceptions */ +HPy h_BaseException; HPy h_Exception; +HPy h_StopAsyncIteration; +HPy h_StopIteration; +HPy h_GeneratorExit; +HPy h_ArithmeticError; +HPy h_LookupError; +HPy h_AssertionError; +HPy h_AttributeError; +HPy h_BufferError; +HPy h_EOFError; +HPy h_FloatingPointError; +HPy h_OSError; +HPy h_ImportError; +HPy h_ModuleNotFoundError; HPy h_IndexError; +HPy h_KeyError; +HPy h_KeyboardInterrupt; +HPy h_MemoryError; +HPy h_NameError; HPy h_OverflowError; +HPy h_RuntimeError; +HPy h_RecursionError; +HPy h_NotImplementedError; +HPy h_SyntaxError; +HPy h_IndentationError; +HPy h_TabError; +HPy h_ReferenceError; HPy h_SystemError; +HPy h_SystemExit; HPy h_TypeError; +HPy h_UnboundLocalError; +HPy h_UnicodeError; +HPy h_UnicodeEncodeError; +HPy h_UnicodeDecodeError; +HPy h_UnicodeTranslateError; HPy h_ValueError; +HPy h_ZeroDivisionError; +HPy h_BlockingIOError; +HPy h_BrokenPipeError; +HPy h_ChildProcessError; +HPy h_ConnectionError; +HPy h_ConnectionAbortedError; +HPy h_ConnectionRefusedError; +HPy h_ConnectionResetError; +HPy h_FileExistsError; +HPy h_FileNotFoundError; +HPy h_InterruptedError; +HPy h_IsADirectoryError; +HPy h_NotADirectoryError; +HPy h_PermissionError; +HPy h_ProcessLookupError; +HPy h_TimeoutError; +// EnvironmentError, IOError and WindowsError are intentionally omitted (they +// are all aliases of OSError since Python 3.3). + +/* Warnings */ +HPy h_Warning; +HPy h_UserWarning; +HPy h_DeprecationWarning; +HPy h_PendingDeprecationWarning; +HPy h_SyntaxWarning; +HPy h_RuntimeWarning; +HPy h_FutureWarning; +HPy h_ImportWarning; +HPy h_UnicodeWarning; +HPy h_BytesWarning; +HPy h_ResourceWarning; + +/* Types */ HPy h_BaseObjectType; /* built-in 'object' */ HPy h_TypeType; /* built-in 'type' */ HPy h_LongType; /* built-in 'int' */ @@ -99,6 +166,7 @@ HPy HPy_InPlaceOr(HPyContext ctx, HPy h1, HPy h2); /* pyerrors.h */ void HPyErr_SetString(HPyContext ctx, HPy h_type, const char *message); +void HPyErr_SetObject(HPyContext ctx, HPy h_type, HPy h_value); /* note: HPyErr_Occurred() returns a flag 0-or-1, instead of a 'PyObject *' */ int HPyErr_Occurred(HPyContext ctx); HPy HPyErr_NoMemory(HPyContext ctx); diff --git a/hpy/universal/src/autogen_ctx_def.h b/hpy/universal/src/autogen_ctx_def.h index 8361769bd..5a34ce240 100644 --- a/hpy/universal/src/autogen_ctx_def.h +++ b/hpy/universal/src/autogen_ctx_def.h @@ -13,12 +13,70 @@ struct _HPyContext_s global_ctx = { .h_None = {CONSTANT_H_NONE}, .h_True = {CONSTANT_H_TRUE}, .h_False = {CONSTANT_H_FALSE}, + .h_BaseException = {CONSTANT_H_BASEEXCEPTION}, .h_Exception = {CONSTANT_H_EXCEPTION}, + .h_StopAsyncIteration = {CONSTANT_H_STOPASYNCITERATION}, + .h_StopIteration = {CONSTANT_H_STOPITERATION}, + .h_GeneratorExit = {CONSTANT_H_GENERATOREXIT}, + .h_ArithmeticError = {CONSTANT_H_ARITHMETICERROR}, + .h_LookupError = {CONSTANT_H_LOOKUPERROR}, + .h_AssertionError = {CONSTANT_H_ASSERTIONERROR}, + .h_AttributeError = {CONSTANT_H_ATTRIBUTEERROR}, + .h_BufferError = {CONSTANT_H_BUFFERERROR}, + .h_EOFError = {CONSTANT_H_EOFERROR}, + .h_FloatingPointError = {CONSTANT_H_FLOATINGPOINTERROR}, + .h_OSError = {CONSTANT_H_OSERROR}, + .h_ImportError = {CONSTANT_H_IMPORTERROR}, + .h_ModuleNotFoundError = {CONSTANT_H_MODULENOTFOUNDERROR}, .h_IndexError = {CONSTANT_H_INDEXERROR}, + .h_KeyError = {CONSTANT_H_KEYERROR}, + .h_KeyboardInterrupt = {CONSTANT_H_KEYBOARDINTERRUPT}, + .h_MemoryError = {CONSTANT_H_MEMORYERROR}, + .h_NameError = {CONSTANT_H_NAMEERROR}, .h_OverflowError = {CONSTANT_H_OVERFLOWERROR}, + .h_RuntimeError = {CONSTANT_H_RUNTIMEERROR}, + .h_RecursionError = {CONSTANT_H_RECURSIONERROR}, + .h_NotImplementedError = {CONSTANT_H_NOTIMPLEMENTEDERROR}, + .h_SyntaxError = {CONSTANT_H_SYNTAXERROR}, + .h_IndentationError = {CONSTANT_H_INDENTATIONERROR}, + .h_TabError = {CONSTANT_H_TABERROR}, + .h_ReferenceError = {CONSTANT_H_REFERENCEERROR}, .h_SystemError = {CONSTANT_H_SYSTEMERROR}, + .h_SystemExit = {CONSTANT_H_SYSTEMEXIT}, .h_TypeError = {CONSTANT_H_TYPEERROR}, + .h_UnboundLocalError = {CONSTANT_H_UNBOUNDLOCALERROR}, + .h_UnicodeError = {CONSTANT_H_UNICODEERROR}, + .h_UnicodeEncodeError = {CONSTANT_H_UNICODEENCODEERROR}, + .h_UnicodeDecodeError = {CONSTANT_H_UNICODEDECODEERROR}, + .h_UnicodeTranslateError = {CONSTANT_H_UNICODETRANSLATEERROR}, .h_ValueError = {CONSTANT_H_VALUEERROR}, + .h_ZeroDivisionError = {CONSTANT_H_ZERODIVISIONERROR}, + .h_BlockingIOError = {CONSTANT_H_BLOCKINGIOERROR}, + .h_BrokenPipeError = {CONSTANT_H_BROKENPIPEERROR}, + .h_ChildProcessError = {CONSTANT_H_CHILDPROCESSERROR}, + .h_ConnectionError = {CONSTANT_H_CONNECTIONERROR}, + .h_ConnectionAbortedError = {CONSTANT_H_CONNECTIONABORTEDERROR}, + .h_ConnectionRefusedError = {CONSTANT_H_CONNECTIONREFUSEDERROR}, + .h_ConnectionResetError = {CONSTANT_H_CONNECTIONRESETERROR}, + .h_FileExistsError = {CONSTANT_H_FILEEXISTSERROR}, + .h_FileNotFoundError = {CONSTANT_H_FILENOTFOUNDERROR}, + .h_InterruptedError = {CONSTANT_H_INTERRUPTEDERROR}, + .h_IsADirectoryError = {CONSTANT_H_ISADIRECTORYERROR}, + .h_NotADirectoryError = {CONSTANT_H_NOTADIRECTORYERROR}, + .h_PermissionError = {CONSTANT_H_PERMISSIONERROR}, + .h_ProcessLookupError = {CONSTANT_H_PROCESSLOOKUPERROR}, + .h_TimeoutError = {CONSTANT_H_TIMEOUTERROR}, + .h_Warning = {CONSTANT_H_WARNING}, + .h_UserWarning = {CONSTANT_H_USERWARNING}, + .h_DeprecationWarning = {CONSTANT_H_DEPRECATIONWARNING}, + .h_PendingDeprecationWarning = {CONSTANT_H_PENDINGDEPRECATIONWARNING}, + .h_SyntaxWarning = {CONSTANT_H_SYNTAXWARNING}, + .h_RuntimeWarning = {CONSTANT_H_RUNTIMEWARNING}, + .h_FutureWarning = {CONSTANT_H_FUTUREWARNING}, + .h_ImportWarning = {CONSTANT_H_IMPORTWARNING}, + .h_UnicodeWarning = {CONSTANT_H_UNICODEWARNING}, + .h_BytesWarning = {CONSTANT_H_BYTESWARNING}, + .h_ResourceWarning = {CONSTANT_H_RESOURCEWARNING}, .h_BaseObjectType = {CONSTANT_H_BASEOBJECTTYPE}, .h_TypeType = {CONSTANT_H_TYPETYPE}, .h_LongType = {CONSTANT_H_LONGTYPE}, @@ -81,6 +139,7 @@ struct _HPyContext_s global_ctx = { .ctx_InPlaceXor = &ctx_InPlaceXor, .ctx_InPlaceOr = &ctx_InPlaceOr, .ctx_Err_SetString = &ctx_Err_SetString, + .ctx_Err_SetObject = &ctx_Err_SetObject, .ctx_Err_Occurred = &ctx_Err_Occurred, .ctx_Err_NoMemory = &ctx_Err_NoMemory, .ctx_Err_Clear = &ctx_Err_Clear, diff --git a/hpy/universal/src/handles.c b/hpy/universal/src/handles.c index b6325cc24..79675da25 100644 --- a/hpy/universal/src/handles.c +++ b/hpy/universal/src/handles.c @@ -47,22 +47,85 @@ allocate_more_handles(void) if (h_num_allocated == 0) { new_handles[CONSTANT_H_NULL] = NULL; + /* Constants */ new_handles[CONSTANT_H_NONE] = Py_None; - new_handles[CONSTANT_H_FALSE] = Py_False; new_handles[CONSTANT_H_TRUE] = Py_True; + new_handles[CONSTANT_H_FALSE] = Py_False; + /* Exceptions */ + new_handles[CONSTANT_H_BASEEXCEPTION] = PyExc_BaseException; new_handles[CONSTANT_H_EXCEPTION] = PyExc_Exception; + new_handles[CONSTANT_H_STOPASYNCITERATION] = PyExc_StopAsyncIteration; + new_handles[CONSTANT_H_STOPITERATION] = PyExc_StopIteration; + new_handles[CONSTANT_H_GENERATOREXIT] = PyExc_GeneratorExit; + new_handles[CONSTANT_H_ARITHMETICERROR] = PyExc_ArithmeticError; + new_handles[CONSTANT_H_LOOKUPERROR] = PyExc_LookupError; + new_handles[CONSTANT_H_ASSERTIONERROR] = PyExc_AssertionError; + new_handles[CONSTANT_H_ATTRIBUTEERROR] = PyExc_AttributeError; + new_handles[CONSTANT_H_BUFFERERROR] = PyExc_BufferError; + new_handles[CONSTANT_H_EOFERROR] = PyExc_EOFError; + new_handles[CONSTANT_H_FLOATINGPOINTERROR] = PyExc_FloatingPointError; + new_handles[CONSTANT_H_OSERROR] = PyExc_OSError; + new_handles[CONSTANT_H_IMPORTERROR] = PyExc_ImportError; + new_handles[CONSTANT_H_MODULENOTFOUNDERROR] = PyExc_ModuleNotFoundError; new_handles[CONSTANT_H_INDEXERROR] = PyExc_IndexError; + new_handles[CONSTANT_H_KEYERROR] = PyExc_KeyError; + new_handles[CONSTANT_H_KEYBOARDINTERRUPT] = PyExc_KeyboardInterrupt; + new_handles[CONSTANT_H_MEMORYERROR] = PyExc_MemoryError; + new_handles[CONSTANT_H_NAMEERROR] = PyExc_NameError; new_handles[CONSTANT_H_OVERFLOWERROR] = PyExc_OverflowError; + new_handles[CONSTANT_H_RUNTIMEERROR] = PyExc_RuntimeError; + new_handles[CONSTANT_H_RECURSIONERROR] = PyExc_RecursionError; + new_handles[CONSTANT_H_NOTIMPLEMENTEDERROR] = PyExc_NotImplementedError; + new_handles[CONSTANT_H_SYNTAXERROR] = PyExc_SyntaxError; + new_handles[CONSTANT_H_INDENTATIONERROR] = PyExc_IndentationError; + new_handles[CONSTANT_H_TABERROR] = PyExc_TabError; + new_handles[CONSTANT_H_REFERENCEERROR] = PyExc_ReferenceError; new_handles[CONSTANT_H_SYSTEMERROR] = PyExc_SystemError; + new_handles[CONSTANT_H_SYSTEMEXIT] = PyExc_SystemExit; new_handles[CONSTANT_H_TYPEERROR] = PyExc_TypeError; + new_handles[CONSTANT_H_UNBOUNDLOCALERROR] = PyExc_UnboundLocalError; + new_handles[CONSTANT_H_UNICODEERROR] = PyExc_UnicodeError; + new_handles[CONSTANT_H_UNICODEENCODEERROR] = PyExc_UnicodeEncodeError; + new_handles[CONSTANT_H_UNICODEDECODEERROR] = PyExc_UnicodeDecodeError; + new_handles[CONSTANT_H_UNICODETRANSLATEERROR] = PyExc_UnicodeTranslateError; new_handles[CONSTANT_H_VALUEERROR] = PyExc_ValueError; + new_handles[CONSTANT_H_ZERODIVISIONERROR] = PyExc_ZeroDivisionError; + new_handles[CONSTANT_H_BLOCKINGIOERROR] = PyExc_BlockingIOError; + new_handles[CONSTANT_H_BROKENPIPEERROR] = PyExc_BrokenPipeError; + new_handles[CONSTANT_H_CHILDPROCESSERROR] = PyExc_ChildProcessError; + new_handles[CONSTANT_H_CONNECTIONERROR] = PyExc_ConnectionError; + new_handles[CONSTANT_H_CONNECTIONABORTEDERROR] = PyExc_ConnectionAbortedError; + new_handles[CONSTANT_H_CONNECTIONREFUSEDERROR] = PyExc_ConnectionRefusedError; + new_handles[CONSTANT_H_CONNECTIONRESETERROR] = PyExc_ConnectionResetError; + new_handles[CONSTANT_H_FILEEXISTSERROR] = PyExc_FileExistsError; + new_handles[CONSTANT_H_FILENOTFOUNDERROR] = PyExc_FileNotFoundError; + new_handles[CONSTANT_H_INTERRUPTEDERROR] = PyExc_InterruptedError; + new_handles[CONSTANT_H_ISADIRECTORYERROR] = PyExc_IsADirectoryError; + new_handles[CONSTANT_H_NOTADIRECTORYERROR] = PyExc_NotADirectoryError; + new_handles[CONSTANT_H_PERMISSIONERROR] = PyExc_PermissionError; + new_handles[CONSTANT_H_PROCESSLOOKUPERROR] = PyExc_ProcessLookupError; + new_handles[CONSTANT_H_TIMEOUTERROR] = PyExc_TimeoutError; + /* Warnings */ + new_handles[CONSTANT_H_WARNING] = PyExc_Warning; + new_handles[CONSTANT_H_USERWARNING] = PyExc_UserWarning; + new_handles[CONSTANT_H_DEPRECATIONWARNING] = PyExc_DeprecationWarning; + new_handles[CONSTANT_H_PENDINGDEPRECATIONWARNING] = PyExc_PendingDeprecationWarning; + new_handles[CONSTANT_H_SYNTAXWARNING] = PyExc_SyntaxWarning; + new_handles[CONSTANT_H_RUNTIMEWARNING] = PyExc_RuntimeWarning; + new_handles[CONSTANT_H_FUTUREWARNING] = PyExc_FutureWarning; + new_handles[CONSTANT_H_IMPORTWARNING] = PyExc_ImportWarning; + new_handles[CONSTANT_H_UNICODEWARNING] = PyExc_UnicodeWarning; + new_handles[CONSTANT_H_BYTESWARNING] = PyExc_BytesWarning; + new_handles[CONSTANT_H_RESOURCEWARNING] = PyExc_ResourceWarning; + /* Types */ new_handles[CONSTANT_H_BASEOBJECTTYPE] = (PyObject *)&PyBaseObject_Type; new_handles[CONSTANT_H_TYPETYPE] = (PyObject *)&PyType_Type; new_handles[CONSTANT_H_LONGTYPE] = (PyObject *)&PyLong_Type; new_handles[CONSTANT_H_UNICODETYPE] = (PyObject *)&PyUnicode_Type; new_handles[CONSTANT_H_TUPLETYPE] = (PyObject *)&PyTuple_Type; new_handles[CONSTANT_H_LISTTYPE] = (PyObject *)&PyList_Type; - hpy_assert(CONSTANT_H__TOTAL == 16, + /* Check total */ + hpy_assert(CONSTANT_H__TOTAL == 74, "update handles.c with the list of constants"); } diff --git a/hpy/universal/src/handles.h b/hpy/universal/src/handles.h index f9bb98413..b9fb0f9ad 100644 --- a/hpy/universal/src/handles.h +++ b/hpy/universal/src/handles.h @@ -6,21 +6,84 @@ // this should maybe autogenerated from public_api.h enum { CONSTANT_H_NULL = 0, + /* Constants */ CONSTANT_H_NONE, CONSTANT_H_TRUE, CONSTANT_H_FALSE, + /* Exceptions */ + CONSTANT_H_BASEEXCEPTION, CONSTANT_H_EXCEPTION, + CONSTANT_H_STOPASYNCITERATION, + CONSTANT_H_STOPITERATION, + CONSTANT_H_GENERATOREXIT, + CONSTANT_H_ARITHMETICERROR, + CONSTANT_H_LOOKUPERROR, + CONSTANT_H_ASSERTIONERROR, + CONSTANT_H_ATTRIBUTEERROR, + CONSTANT_H_BUFFERERROR, + CONSTANT_H_EOFERROR, + CONSTANT_H_FLOATINGPOINTERROR, + CONSTANT_H_OSERROR, + CONSTANT_H_IMPORTERROR, + CONSTANT_H_MODULENOTFOUNDERROR, CONSTANT_H_INDEXERROR, + CONSTANT_H_KEYERROR, + CONSTANT_H_KEYBOARDINTERRUPT, + CONSTANT_H_MEMORYERROR, + CONSTANT_H_NAMEERROR, CONSTANT_H_OVERFLOWERROR, + CONSTANT_H_RUNTIMEERROR, + CONSTANT_H_RECURSIONERROR, + CONSTANT_H_NOTIMPLEMENTEDERROR, + CONSTANT_H_SYNTAXERROR, + CONSTANT_H_INDENTATIONERROR, + CONSTANT_H_TABERROR, + CONSTANT_H_REFERENCEERROR, CONSTANT_H_SYSTEMERROR, + CONSTANT_H_SYSTEMEXIT, CONSTANT_H_TYPEERROR, + CONSTANT_H_UNBOUNDLOCALERROR, + CONSTANT_H_UNICODEERROR, + CONSTANT_H_UNICODEENCODEERROR, + CONSTANT_H_UNICODEDECODEERROR, + CONSTANT_H_UNICODETRANSLATEERROR, CONSTANT_H_VALUEERROR, + CONSTANT_H_ZERODIVISIONERROR, + CONSTANT_H_BLOCKINGIOERROR, + CONSTANT_H_BROKENPIPEERROR, + CONSTANT_H_CHILDPROCESSERROR, + CONSTANT_H_CONNECTIONERROR, + CONSTANT_H_CONNECTIONABORTEDERROR, + CONSTANT_H_CONNECTIONREFUSEDERROR, + CONSTANT_H_CONNECTIONRESETERROR, + CONSTANT_H_FILEEXISTSERROR, + CONSTANT_H_FILENOTFOUNDERROR, + CONSTANT_H_INTERRUPTEDERROR, + CONSTANT_H_ISADIRECTORYERROR, + CONSTANT_H_NOTADIRECTORYERROR, + CONSTANT_H_PERMISSIONERROR, + CONSTANT_H_PROCESSLOOKUPERROR, + CONSTANT_H_TIMEOUTERROR, + /* Warnings */ + CONSTANT_H_WARNING, + CONSTANT_H_USERWARNING, + CONSTANT_H_DEPRECATIONWARNING, + CONSTANT_H_PENDINGDEPRECATIONWARNING, + CONSTANT_H_SYNTAXWARNING, + CONSTANT_H_RUNTIMEWARNING, + CONSTANT_H_FUTUREWARNING, + CONSTANT_H_IMPORTWARNING, + CONSTANT_H_UNICODEWARNING, + CONSTANT_H_BYTESWARNING, + CONSTANT_H_RESOURCEWARNING, + /* Types */ CONSTANT_H_BASEOBJECTTYPE, CONSTANT_H_TYPETYPE, CONSTANT_H_LONGTYPE, CONSTANT_H_UNICODETYPE, CONSTANT_H_TUPLETYPE, CONSTANT_H_LISTTYPE, + /* Total */ CONSTANT_H__TOTAL, }; diff --git a/test/test_hpyerr.py b/test/test_hpyerr.py index 08e6bb602..529d299e8 100644 --- a/test/test_hpyerr.py +++ b/test/test_hpyerr.py @@ -1,5 +1,8 @@ +import pytest as pytest_collecting + from .support import HPyTest + class TestErr(HPyTest): def test_NoMemory(self): @@ -70,35 +73,271 @@ def test_HPyErr_Cleared(self): assert mod.f() is None assert sys.exc_info() == (None, None, None) - def check_exception_constant(self, cls): + def test_HPyErr_SetString(self): import pytest mod = self.make_module(""" HPyDef_METH(f, "f", f_impl, HPyFunc_NOARGS) static HPy f_impl(HPyContext ctx, HPy self) - {{ - HPyErr_SetString(ctx, ctx->h_{cls_name}, "error message"); + { + HPyErr_SetString(ctx, ctx->h_ValueError, "error message"); return HPy_NULL; - }} + } @EXPORT(f) @INIT - """.format(cls_name=cls.__name__)) - with pytest.raises(cls): + """) + with pytest.raises(ValueError) as err: mod.f() + assert str(err.value) == "error message" + + def test_HPyErr_SetObject(self): + import pytest + mod = self.make_module(""" + HPyDef_METH(f, "f", f_impl, HPyFunc_O) + static HPy f_impl(HPyContext ctx, HPy self, HPy arg) + { + HPyErr_SetObject(ctx, ctx->h_ValueError, arg); + return HPy_NULL; + } + @EXPORT(f) + @INIT + """) + with pytest.raises(ValueError) as err: + mod.f(ValueError("error message")) + assert str(err.value) == "error message" + + def test_h_exceptions(self): + import pytest + mod = self.make_module(""" + HPyDef_METH(f, "f", f_impl, HPyFunc_O) + static HPy f_impl(HPyContext ctx, HPy self, HPy arg) + { + HPy h_dict, h_err; + h_dict = HPyDict_New(ctx); + HPy_SetItem_s(ctx, h_dict, "BaseException", ctx->h_BaseException); + HPy_SetItem_s(ctx, h_dict, "Exception", ctx->h_Exception); + HPy_SetItem_s(ctx, h_dict, "StopAsyncIteration", ctx->h_StopAsyncIteration); + HPy_SetItem_s(ctx, h_dict, "StopIteration", ctx->h_StopIteration); + HPy_SetItem_s(ctx, h_dict, "GeneratorExit", ctx->h_GeneratorExit); + HPy_SetItem_s(ctx, h_dict, "ArithmeticError", ctx->h_ArithmeticError); + HPy_SetItem_s(ctx, h_dict, "LookupError", ctx->h_LookupError); + HPy_SetItem_s(ctx, h_dict, "AssertionError", ctx->h_AssertionError); + HPy_SetItem_s(ctx, h_dict, "AttributeError", ctx->h_AttributeError); + HPy_SetItem_s(ctx, h_dict, "BufferError", ctx->h_BufferError); + HPy_SetItem_s(ctx, h_dict, "EOFError", ctx->h_EOFError); + HPy_SetItem_s(ctx, h_dict, "FloatingPointError", ctx->h_FloatingPointError); + HPy_SetItem_s(ctx, h_dict, "OSError", ctx->h_OSError); + HPy_SetItem_s(ctx, h_dict, "ImportError", ctx->h_ImportError); + HPy_SetItem_s(ctx, h_dict, "ModuleNotFoundError", ctx->h_ModuleNotFoundError); + HPy_SetItem_s(ctx, h_dict, "IndexError", ctx->h_IndexError); + HPy_SetItem_s(ctx, h_dict, "KeyError", ctx->h_KeyError); + HPy_SetItem_s(ctx, h_dict, "KeyboardInterrupt", ctx->h_KeyboardInterrupt); + HPy_SetItem_s(ctx, h_dict, "MemoryError", ctx->h_MemoryError); + HPy_SetItem_s(ctx, h_dict, "NameError", ctx->h_NameError); + HPy_SetItem_s(ctx, h_dict, "OverflowError", ctx->h_OverflowError); + HPy_SetItem_s(ctx, h_dict, "RuntimeError", ctx->h_RuntimeError); + HPy_SetItem_s(ctx, h_dict, "RecursionError", ctx->h_RecursionError); + HPy_SetItem_s(ctx, h_dict, "NotImplementedError", ctx->h_NotImplementedError); + HPy_SetItem_s(ctx, h_dict, "SyntaxError", ctx->h_SyntaxError); + HPy_SetItem_s(ctx, h_dict, "IndentationError", ctx->h_IndentationError); + HPy_SetItem_s(ctx, h_dict, "TabError", ctx->h_TabError); + HPy_SetItem_s(ctx, h_dict, "ReferenceError", ctx->h_ReferenceError); + HPy_SetItem_s(ctx, h_dict, "SystemError", ctx->h_SystemError); + HPy_SetItem_s(ctx, h_dict, "SystemExit", ctx->h_SystemExit); + HPy_SetItem_s(ctx, h_dict, "TypeError", ctx->h_TypeError); + HPy_SetItem_s(ctx, h_dict, "UnboundLocalError", ctx->h_UnboundLocalError); + HPy_SetItem_s(ctx, h_dict, "ValueError", ctx->h_ValueError); + HPy_SetItem_s(ctx, h_dict, "ZeroDivisionError", ctx->h_ZeroDivisionError); + HPy_SetItem_s(ctx, h_dict, "BlockingIOError", ctx->h_BlockingIOError); + HPy_SetItem_s(ctx, h_dict, "BrokenPipeError", ctx->h_BrokenPipeError); + HPy_SetItem_s(ctx, h_dict, "ChildProcessError", ctx->h_ChildProcessError); + HPy_SetItem_s(ctx, h_dict, "ConnectionError", ctx->h_ConnectionError); + HPy_SetItem_s(ctx, h_dict, "ConnectionAbortedError", ctx->h_ConnectionAbortedError); + HPy_SetItem_s(ctx, h_dict, "ConnectionRefusedError", ctx->h_ConnectionRefusedError); + HPy_SetItem_s(ctx, h_dict, "ConnectionResetError", ctx->h_ConnectionResetError); + HPy_SetItem_s(ctx, h_dict, "FileExistsError", ctx->h_FileExistsError); + HPy_SetItem_s(ctx, h_dict, "FileNotFoundError", ctx->h_FileNotFoundError); + HPy_SetItem_s(ctx, h_dict, "InterruptedError", ctx->h_InterruptedError); + HPy_SetItem_s(ctx, h_dict, "IsADirectoryError", ctx->h_IsADirectoryError); + HPy_SetItem_s(ctx, h_dict, "NotADirectoryError", ctx->h_NotADirectoryError); + HPy_SetItem_s(ctx, h_dict, "PermissionError", ctx->h_PermissionError); + HPy_SetItem_s(ctx, h_dict, "ProcessLookupError", ctx->h_ProcessLookupError); + HPy_SetItem_s(ctx, h_dict, "TimeoutError", ctx->h_TimeoutError); + h_err = HPy_GetItem(ctx, h_dict, arg); + if (HPy_IsNull(h_err)) { + HPy_FatalError(ctx, "missing exception type"); + } + HPyErr_SetString(ctx, h_err, "error message"); + HPy_Close(ctx, h_dict); + HPy_Close(ctx, h_err); + return HPy_NULL; + } + @EXPORT(f) + @INIT + """) + + def check_exception(cls): + with pytest.raises(cls): + mod.f(cls.__name__) + + check_exception(BaseException) + check_exception(Exception) + check_exception(StopAsyncIteration) + check_exception(StopIteration) + check_exception(GeneratorExit) + check_exception(ArithmeticError) + check_exception(LookupError) + check_exception(AssertionError) + check_exception(AttributeError) + check_exception(BufferError) + check_exception(EOFError) + check_exception(FloatingPointError) + check_exception(OSError) + check_exception(ImportError) + check_exception(ModuleNotFoundError) + check_exception(IndexError) + check_exception(KeyError) + check_exception(KeyboardInterrupt) + check_exception(MemoryError) + check_exception(NameError) + check_exception(OverflowError) + check_exception(RuntimeError) + check_exception(RecursionError) + check_exception(NotImplementedError) + check_exception(SyntaxError) + check_exception(IndentationError) + check_exception(TabError) + check_exception(ReferenceError) + check_exception(SystemError) + check_exception(SystemExit) + check_exception(TypeError) + check_exception(UnboundLocalError) + check_exception(ValueError) + check_exception(ZeroDivisionError) + check_exception(BlockingIOError) + check_exception(BrokenPipeError) + check_exception(ChildProcessError) + check_exception(ConnectionError) + check_exception(ConnectionAbortedError) + check_exception(ConnectionRefusedError) + check_exception(ConnectionResetError) + check_exception(FileExistsError) + check_exception(FileNotFoundError) + check_exception(InterruptedError) + check_exception(IsADirectoryError) + check_exception(NotADirectoryError) + check_exception(PermissionError) + check_exception(ProcessLookupError) + check_exception(TimeoutError) + # EnvironmentError and IOError are not explicitly defined by HPy + # but they work because they are actually OSError. + check_exception(EnvironmentError) + check_exception(IOError) - def test_h_Exception(self): - self.check_exception_constant(Exception) + @pytest_collecting.mark.xfail(True, reason=( + "Creating the unicode exceptions requires something like HPyCall" + " and that isn't implemented yet." + )) + def test_h_unicode_exceptions(self): + import pytest + mod = self.make_module(""" + HPyDef_METH(f, "f", f_impl, HPyFunc_VARARGS) + static HPy f_impl(HPyContext ctx, HPy self, + HPy *args, HPy_ssize_t nargs) + { + HPy h_key, h_args, h_kw; + HPy h_dict, h_err, h_err_value; + + if (!HPyArg_Parse(ctx, NULL, args, nargs, "OOO", &h_key, &h_args, &h_kw)) + return HPy_NULL; + + h_dict = HPyDict_New(ctx); + if (HPy_IsNull(h_dict)) { + return HPy_NULL; + } + HPy_SetItem_s(ctx, h_dict, "UnicodeError", ctx->h_UnicodeError); + HPy_SetItem_s(ctx, h_dict, "UnicodeEncodeError", ctx->h_UnicodeEncodeError); + HPy_SetItem_s(ctx, h_dict, "UnicodeDecodeError", ctx->h_UnicodeDecodeError); + HPy_SetItem_s(ctx, h_dict, "UnicodeTranslateError", ctx->h_UnicodeTranslateError); + + h_err = HPy_GetItem(ctx, h_dict, h_key); + if (HPy_IsNull(h_err)) { + HPy_Close(ctx, h_dict); + return HPy_NULL; + } + h_err_value = HPy_Call(ctx, h_err, h_args, h_kw); + if (HPy_IsNull(h_err_value)) { + HPy_Close(ctx, h_dict); + HPy_Close(ctx, h_err); + return HPy_NULL; + } + + HPyErr_SetObject(ctx, h_err, h_err_value); + HPy_Close(ctx, h_dict); + HPy_Close(ctx, h_err); + HPy_Close(ctx, h_err_value); + return HPy_NULL; + } + @EXPORT(f) + @INIT + """) - def test_h_IndexError(self): - self.check_exception_constant(IndexError) + def check_exception(cls, *args, **kw): + with pytest.raises(cls): + mod.f(cls.__name__, args, kw) - def test_h_OverflowError(self): - self.check_exception_constant(OverflowError) + check_exception(UnicodeError) + check_exception( + UnicodeEncodeError, "utf-8", "object", 0, 2, "reason" + ) + check_exception( + UnicodeDecodeError, "utf-8", b"object", 0, 2, "reason" + ) + check_exception(UnicodeTranslateError, "object", 0, 2, "reason") - def test_h_SystemError(self): - self.check_exception_constant(SystemError) + def test_h_warnings(self): + import pytest + mod = self.make_module(""" + HPyDef_METH(f, "f", f_impl, HPyFunc_O) + static HPy f_impl(HPyContext ctx, HPy self, HPy arg) + { + HPy h_dict, h_err; + h_dict = HPyDict_New(ctx); + HPy_SetItem_s(ctx, h_dict, "Warning", ctx->h_Warning); + HPy_SetItem_s(ctx, h_dict, "UserWarning", ctx->h_UserWarning); + HPy_SetItem_s(ctx, h_dict, "DeprecationWarning", ctx->h_DeprecationWarning); + HPy_SetItem_s(ctx, h_dict, "PendingDeprecationWarning", ctx->h_PendingDeprecationWarning); + HPy_SetItem_s(ctx, h_dict, "SyntaxWarning", ctx->h_SyntaxWarning); + HPy_SetItem_s(ctx, h_dict, "RuntimeWarning", ctx->h_RuntimeWarning); + HPy_SetItem_s(ctx, h_dict, "FutureWarning", ctx->h_FutureWarning); + HPy_SetItem_s(ctx, h_dict, "ImportWarning", ctx->h_ImportWarning); + HPy_SetItem_s(ctx, h_dict, "UnicodeWarning", ctx->h_UnicodeWarning); + HPy_SetItem_s(ctx, h_dict, "BytesWarning", ctx->h_BytesWarning); + HPy_SetItem_s(ctx, h_dict, "ResourceWarning", ctx->h_ResourceWarning); + h_err = HPy_GetItem(ctx, h_dict, arg); + if (HPy_IsNull(h_err)) { + HPy_FatalError(ctx, "missing exception type"); + } + HPyErr_SetString(ctx, h_err, "error message"); + HPy_Close(ctx, h_dict); + HPy_Close(ctx, h_err); + return HPy_NULL; + } + @EXPORT(f) + @INIT + """) - def test_h_TypeError(self): - self.check_exception_constant(TypeError) + def check_warning(cls): + with pytest.raises(cls): + mod.f(cls.__name__) - def test_h_ValueError(self): - self.check_exception_constant(ValueError) + check_warning(Warning) + check_warning(UserWarning) + check_warning(DeprecationWarning) + check_warning(PendingDeprecationWarning) + check_warning(SyntaxWarning) + check_warning(RuntimeWarning) + check_warning(FutureWarning) + check_warning(ImportWarning) + check_warning(UnicodeWarning) + check_warning(BytesWarning) + check_warning(ResourceWarning) diff --git a/test/test_importing.py b/test/test_importing.py index d7cd1bd6c..7d0e7ceca 100644 --- a/test/test_importing.py +++ b/test/test_importing.py @@ -1,4 +1,5 @@ -import pytest +import pytest as pytest_collecting + from .support import HPyTest # this function should probably goes somewhere into hpy.universal and/or and @@ -16,7 +17,7 @@ def import_module_properly(mod): class TestImporting(HPyTest): - @pytest.mark.xfail + @pytest_collecting.mark.xfail def test_importing_attributes(self): import sys modname = 'mytest'