Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-104469 Convert _testcapi/exceptions to use AC #104502

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Follow the guideline
  • Loading branch information
corona10 committed May 17, 2023
commit 03de258613f2e365762143bc444271390f04be11
1 change: 0 additions & 1 deletion 1 Include/internal/pycore_global_objects_fini_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion 1 Include/internal/pycore_global_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ struct _Py_global_strings {
STRUCT_FOR_ID(errors)
STRUCT_FOR_ID(event)
STRUCT_FOR_ID(eventmask)
STRUCT_FOR_ID(exc)
STRUCT_FOR_ID(exc_type)
STRUCT_FOR_ID(exc_value)
STRUCT_FOR_ID(excepthook)
Expand Down
1 change: 0 additions & 1 deletion 1 Include/internal/pycore_runtime_init_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions 3 Include/internal/pycore_unicodeobject_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 18 additions & 25 deletions 43 Modules/_testcapi/clinic/exceptions.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 19 additions & 23 deletions 42 Modules/_testcapi/exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ module _testcapi

/*[clinic input]
_testcapi.err_set_raised
exc: object
exception as exc: object
/
Test PyErr_SetRaisedException C API.
[clinic start generated code]*/

static PyObject *
_testcapi_err_set_raised(PyObject *module, PyObject *exc)
/*[clinic end generated code: output=0a0c7743961fcae5 input=65d91c54e94cb5dd]*/
/*[clinic end generated code: output=0a0c7743961fcae5 input=c5f7331864a94df9]*/
{
Py_INCREF(exc);
PyErr_SetRaisedException(exc);
Expand Down Expand Up @@ -51,15 +50,16 @@ err_restore(PyObject *self, PyObject *args) {

/*[clinic input]
_testcapi.exception_print
exc: object
exception as exc: object
legacy: bool = False
corona10 marked this conversation as resolved.
Show resolved Hide resolved
/

To test the format of exceptions as printed out.
[clinic start generated code]*/

static PyObject *
_testcapi_exception_print_impl(PyObject *module, PyObject *exc, int legacy)
/*[clinic end generated code: output=3f04fe0c18412ae0 input=16da48a5d8581472]*/
/*[clinic end generated code: output=3f04fe0c18412ae0 input=c76f42cb94136dbf]*/
{
if (legacy) {
PyObject *tb = NULL;
Expand All @@ -81,44 +81,43 @@ _testcapi.make_exception_with_doc
doc: str = NULL
base: object = NULL
dict: object = NULL

Test PyErr_NewExceptionWithDoc (also exercise PyErr_NewException). Run via Lib/test/test_exceptions.py
[clinic start generated code]*/

static PyObject *
_testcapi_make_exception_with_doc_impl(PyObject *module, const char *name,
const char *doc, PyObject *base,
PyObject *dict)
/*[clinic end generated code: output=439f0d963c1ce2c4 input=4c78cd84f3d2ef1e]*/
/*[clinic end generated code: output=439f0d963c1ce2c4 input=23a73013f8a8795a]*/
{
return PyErr_NewExceptionWithDoc(name, doc, base, dict);
}

/*[clinic input]
_testcapi.exc_set_object
exc: object
exception as exc: object
obj: object
corona10 marked this conversation as resolved.
Show resolved Hide resolved
Test PyErr_SetObject C API.
[clinic start generated code]*/

static PyObject *
_testcapi_exc_set_object_impl(PyObject *module, PyObject *exc, PyObject *obj)
/*[clinic end generated code: output=34c8c7c83e5c8463 input=a5b44b5f4839a8f0]*/
/*[clinic end generated code: output=34c8c7c83e5c8463 input=d2ccbcb97e67d3c2]*/
{
PyErr_SetObject(exc, obj);
return NULL;
}

/*[clinic input]
_testcapi.exc_set_object_fetch
exc: object
exception as exc: object
obj: object
Test PyErr_SetObject and PyErr_Fetch C APIs.
[clinic start generated code]*/

static PyObject *
_testcapi_exc_set_object_fetch_impl(PyObject *module, PyObject *exc,
PyObject *obj)
/*[clinic end generated code: output=7a5ff5f6d3cf687f input=6940a2113786ed2b]*/
/*[clinic end generated code: output=7a5ff5f6d3cf687f input=0f2675f24fe95093]*/
{
PyObject *type;
PyObject *value;
Expand All @@ -133,15 +132,14 @@ _testcapi_exc_set_object_fetch_impl(PyObject *module, PyObject *exc,

/*[clinic input]
_testcapi.raise_exception
exc: object
exception as exc: object
num_args: int
/
Test PyErr_SetObject for raising exception
[clinic start generated code]*/

static PyObject *
_testcapi_raise_exception_impl(PyObject *module, PyObject *exc, int num_args)
/*[clinic end generated code: output=eb0a9c5d69e0542d input=912b1bb1cd2346c3]*/
/*[clinic end generated code: output=eb0a9c5d69e0542d input=83d6262c3829d088]*/
{
PyObject *exc_args = PyTuple_New(num_args);
if (exc_args == NULL) {
Expand Down Expand Up @@ -178,13 +176,14 @@ _testcapi.fatal_error
message: str(accept={robuffer})
release_gil: bool = False
/

fatal_error(message, release_gil=False): call Py_FatalError(message)
[clinic start generated code]*/

static PyObject *
_testcapi_fatal_error_impl(PyObject *module, const char *message,
int release_gil)
/*[clinic end generated code: output=9c3237116e6a03e8 input=56f76191e4b152d7]*/
/*[clinic end generated code: output=9c3237116e6a03e8 input=3d1709d2936fe086]*/
{
if (release_gil) {
Py_BEGIN_ALLOW_THREADS
Expand All @@ -204,13 +203,12 @@ _testcapi.set_exc_info
new_value: object
new_tb: object
/
Test PyErr_SetExcInfo C API.
[clinic start generated code]*/

static PyObject *
_testcapi_set_exc_info_impl(PyObject *module, PyObject *new_type,
PyObject *new_value, PyObject *new_tb)
/*[clinic end generated code: output=b55fa35dec31300e input=ce612545fb3f7200]*/
/*[clinic end generated code: output=b55fa35dec31300e input=ea9f19e0f55fe5b3]*/
{
PyObject *type, *value, *tb;
PyErr_GetExcInfo(&type, &value, &tb);
Expand All @@ -234,12 +232,11 @@ _testcapi_set_exc_info_impl(PyObject *module, PyObject *new_type,
_testcapi.set_exception
new_exc: object
/
Test PyErr_SetHandledException C API.
[clinic start generated code]*/

static PyObject *
_testcapi_set_exception(PyObject *module, PyObject *new_exc)
/*[clinic end generated code: output=8b969b35d029e96d input=356cd44e13128aa0]*/
/*[clinic end generated code: output=8b969b35d029e96d input=c89d4ca966c69738]*/
{
PyObject *exc = PyErr_GetHandledException();
assert(PyExceptionInstance_Check(exc) || exc == NULL);
Expand All @@ -249,17 +246,16 @@ _testcapi_set_exception(PyObject *module, PyObject *new_exc)

/*[clinic input]
_testcapi.write_unraisable_exc
exc: object
exception as exc: object
err_msg: object
obj: object
/
Test _PyErr_WriteUnraisableMsg C API.
[clinic start generated code]*/

static PyObject *
_testcapi_write_unraisable_exc_impl(PyObject *module, PyObject *exc,
PyObject *err_msg, PyObject *obj)
/*[clinic end generated code: output=39827c5e0a8c2092 input=35e060a34a8d388a]*/
/*[clinic end generated code: output=39827c5e0a8c2092 input=582498da5b2ee6cf]*/
{

const char *err_msg_utf8;
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.