Skip to content

Commit

Permalink
Merge pull request #88 from lelit/issue78
Browse files Browse the repository at this point in the history
Another attempt at fixing compilation on MacOS
  • Loading branch information
lelit committed Dec 15, 2017
2 parents 3db2a99 + 235ac31 commit afb19d4
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ build:
script:
- git submodule update --init --recursive
- python3 -m venv env
- env/bin/pip install cibuildwheel==0.5.1 twine
- env/bin/pip install cibuildwheel==0.6.0 twine
- env/bin/cibuildwheel
- env/bin/twine upload wheelhouse/*.whl
12 changes: 5 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@ install:
script:
- pip3 install . && pytest tests
- |
if [ $TRAVIS_OS_NAME = linux ]; then
pip3 install cibuildwheel==0.5.1
cibuildwheel --output-dir wheelhouse
if [[ $TRAVIS_TAG ]]; then
pip install twine
twine upload wheelhouse/*.whl
fi
pip3 install cibuildwheel==0.6.0
cibuildwheel --output-dir wheelhouse
if [[ $TRAVIS_TAG ]]; then
pip install twine
twine upload wheelhouse/*.whl
fi
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ environment:
install: "git submodule update --init --recursive"

build_script:
- "%PYTHON% -m pip install cibuildwheel==0.5.1"
- "%PYTHON% -m pip install cibuildwheel==0.6.0"
- "%PYTHON% -m cibuildwheel --output-dir wheelhouse"
- ps: >-
if ($env:APPVEYOR_REPO_TAG -eq "true") {
Expand Down
22 changes: 20 additions & 2 deletions rapidjson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <structmember.h>

#include <algorithm>
#include <cmath>
#include <string>
#include <vector>

Expand All @@ -26,6 +27,7 @@ using namespace rapidjson;


/* Python < 3.6 compatibility */

#ifndef Py_SETREF
#define Py_SETREF(op, op2) \
do { \
Expand All @@ -35,6 +37,22 @@ using namespace rapidjson;
} while (0)
#endif


/* On some MacOS combo, using Py_IS_XXX() macros does not work (see
https://github.com/python-rapidjson/python-rapidjson/issues/78).
OTOH, MSVC < 2015 does not have std::isxxx() (see
https://stackoverflow.com/questions/38441740/where-is-isnan-in-msvc-2010).
Oh well... */

#if defined (_MSC_VER) && (_MSC_VER < 1900)
#define IS_NAN(x) Py_IS_NAN(x)
#define IS_INF(x) Py_IS_INFINITY(x)
#else
#define IS_NAN(x) std::isnan(x)
#define IS_INF(x) std::isinf(x)
#endif


static PyObject* decimal_type = NULL;
static PyObject* timezone_type = NULL;
static PyObject* timezone_utc = NULL;
Expand Down Expand Up @@ -1652,15 +1670,15 @@ dumps_internal(
if (d == -1.0 && PyErr_Occurred())
return NULL;

if (Py_IS_NAN(d)) {
if (IS_NAN(d)) {
if (numberMode & NM_NAN)
writer->RawValue("NaN", 3, kNumberType);
else {
PyErr_SetString(PyExc_ValueError,
"Out of range float values are not JSON compliant");
return NULL;
}
} else if (Py_IS_INFINITY(d)) {
} else if (IS_INF(d)) {
if (!(numberMode & NM_NAN)) {
PyErr_SetString(PyExc_ValueError,
"Out of range float values are not JSON compliant");
Expand Down

0 comments on commit afb19d4

Please sign in to comment.