Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(python): Add Python 3 compatibility macros for PyInt functions #182

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 2 commits into from
May 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion bindings/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@


setup(
name = 'json-parser python wrapper',
name = 'json-parser-python-wrapper',
version = '1.1.0',
cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules
)
12 changes: 12 additions & 0 deletions bindings/python/wrap_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@

#include "../../json.c"

#include <Python.h>

#if PY_MAJOR_VERSION >= 3
/* Define PyInt_* only for Python 3, where they no longer exist */
#ifndef PyInt_FromLong
#define PyInt_FromLong PyLong_FromLong
#endif
#ifndef PyInt_AsLong
#define PyInt_AsLong PyLong_AsLong
#endif
#endif

PyObject * json_exception = PyErr_NewException("jsonparser.JSONException",
NULL, NULL);

Expand Down
Loading