Skip to content

Commit

Permalink
Properly convert infinity and NaN from C++ to Python
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahAmsel committed Dec 4, 2020
1 parent f914da6 commit f11d925
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/pybind11_json/pybind11_json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

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

#include "nlohmann/json.hpp"

Expand All @@ -34,7 +35,7 @@ namespace pyjson
else if (j.is_number())
{
double number = j.get<double>();
if (number == std::floor(number))
if (isfinite(number) && number == std::floor(number))
{
return py::int_(j.get<long>());
}
Expand Down

0 comments on commit f11d925

Please sign in to comment.