diff options
author | Michael Howitz <mh@gocept.com> | 2022-12-23 09:27:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-23 09:27:18 +0100 |
commit | e2d9d9d49ceadb0c62ab96117ffc4dfa532819e0 (patch) | |
tree | 62e9110f084d572bf06f25115c8f1f794a8f19e9 /src/zope/security/_zope_security_checker.c | |
parent | 831a34f5cf3e2c4297e0da35c4f38e7cf12fac16 (diff) | |
download | zope-security-e2d9d9d49ceadb0c62ab96117ffc4dfa532819e0.tar.gz |
Config with c code template 831a34f5 (#91)
* Drop support for Python 2.7, 3.5, 3.6.
Diffstat (limited to 'src/zope/security/_zope_security_checker.c')
-rw-r--r-- | src/zope/security/_zope_security_checker.c | 53 |
1 files changed, 15 insertions, 38 deletions
diff --git a/src/zope/security/_zope_security_checker.c b/src/zope/security/_zope_security_checker.c index 63b0548..23d7fb9 100644 --- a/src/zope/security/_zope_security_checker.c +++ b/src/zope/security/_zope_security_checker.c @@ -17,55 +17,32 @@ static PyObject *_checkers, *_defaultChecker, *_available_by_default, *NoProxy; static PyObject *Proxy, *thread_local, *CheckerPublic; static PyObject *ForbiddenAttribute, *Unauthorized; -// Compatibility with Python 2 -#if PY_MAJOR_VERSION < 3 - #define IS_STRING PyString_Check - #define MAKE_STRING(name) PyString_AS_STRING(name) +#define PyInt_FromLong PyLong_FromLong - #define FROM_STRING PyString_FromString +#define IS_STRING PyUnicode_Check - #define FROM_STRING_FORMAT PyString_FromFormat +#define MAKE_STRING(name) PyBytes_AS_STRING( \ + PyUnicode_AsUTF8String(name)) - #define INTERN PyString_InternFromString +#define FROM_STRING PyUnicode_FromString - #define MOD_ERROR_VAL +#define FROM_STRING_FORMAT PyUnicode_FromFormat - #define MOD_SUCCESS_VAL(val) +#define INTERN PyUnicode_InternFromString - #define MOD_INIT(name) void init##name(void) +#define MOD_ERROR_VAL NULL - #define MOD_DEF(ob, name, doc, methods) \ - ob = Py_InitModule3(name, methods, doc); +#define MOD_SUCCESS_VAL(val) val -#else +#define MOD_INIT(name) PyMODINIT_FUNC PyInit_##name(void) - #define PyInt_FromLong PyLong_FromLong +#define MOD_DEF(ob, name, doc, methods) \ + static struct PyModuleDef moduledef = { \ + PyModuleDef_HEAD_INIT, name, doc, -1, methods, }; \ + ob = PyModule_Create(&moduledef); - #define IS_STRING PyUnicode_Check - - #define MAKE_STRING(name) PyBytes_AS_STRING( \ - PyUnicode_AsUTF8String(name)) - - #define FROM_STRING PyUnicode_FromString - - #define FROM_STRING_FORMAT PyUnicode_FromFormat - - #define INTERN PyUnicode_InternFromString - - #define MOD_ERROR_VAL NULL - - #define MOD_SUCCESS_VAL(val) val - - #define MOD_INIT(name) PyMODINIT_FUNC PyInit_##name(void) - - #define MOD_DEF(ob, name, doc, methods) \ - static struct PyModuleDef moduledef = { \ - PyModuleDef_HEAD_INIT, name, doc, -1, methods, }; \ - ob = PyModule_Create(&moduledef); - - #define statichere static -#endif +#define statichere static #define DECLARE_STRING(N) static PyObject *str_##N |