-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from ZeroIntensity/size-abi
Size ABI
- Loading branch information
Showing
9 changed files
with
210 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#ifndef PYAWAITABLE_BACKPORT_H | ||
#define PYAWAITABLE_BACKPORT_H | ||
|
||
#ifndef _PyObject_Vectorcall | ||
#define PyObject_CallNoArgs(o) PyObject_CallObject( \ | ||
o, \ | ||
NULL \ | ||
) | ||
static PyObject* _PyObject_VectorcallBackport(PyObject* obj, | ||
PyObject** args, | ||
size_t nargsf, PyObject* kwargs) { | ||
PyObject* tuple = PyTuple_New(nargsf); | ||
if (!tuple) return NULL; | ||
for (size_t i = 0; i < nargsf; i++) { | ||
Py_INCREF(args[i]); | ||
PyTuple_SET_ITEM( | ||
tuple, | ||
i, | ||
args[i] | ||
); | ||
} | ||
PyObject* o = PyObject_Call( | ||
obj, | ||
tuple, | ||
kwargs | ||
); | ||
Py_DECREF(tuple); | ||
return o; | ||
} | ||
#define PyObject_Vectorcall _PyObject_VectorcallBackport | ||
#define PyObject_VectorcallDict _PyObject_FastCallDict | ||
#endif | ||
|
||
#if PY_VERSION_HEX < 0x030c0000 | ||
PyObject *PyErr_GetRaisedException(void) { | ||
PyObject *type, *val, *tb; | ||
PyErr_Fetch(&type, &val, &tb); | ||
PyErr_NormalizeException(&type, &val, &tb); | ||
Py_XDECREF(type); | ||
Py_XDECREF(tb); | ||
// technically some entry in the traceback might be lost; ignore that | ||
return val; | ||
} | ||
|
||
void PyErr_SetRaisedException(PyObject *err) { | ||
PyErr_Restore(err, NULL, NULL); | ||
} | ||
#endif | ||
|
||
|
||
#ifndef Py_NewRef | ||
static inline PyObject* Py_NewRef(PyObject* o) { | ||
Py_INCREF(o); | ||
return o; | ||
} | ||
#endif | ||
|
||
#ifndef Py_XNewRef | ||
static inline PyObject* Py_XNewRef(PyObject* o) { | ||
Py_XINCREF(o); | ||
return o; | ||
} | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
PyAwaitable - CPython API for asynchronous functions. | ||
Docs: https://awaitable.zintensity.dev/ | ||
Source: https://github.com/ZeroIntensity/pyawaitable | ||
You probably don't need this module from Python! This module is for use from the C API. | ||
""" | ||
|
||
from . import abi | ||
from _pyawaitable import _awaitable | ||
from typing import Type | ||
|
||
__all__ = "abi", "Awaitable" | ||
|
||
Awaitable: Type = _awaitable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from _pyawaitable import abiv1 | ||
|
||
__all__ = "v1", | ||
|
||
v1 = abiv1 |
Oops, something went wrong.