test_builtin_casters.cpp
8.57 KB
-
Matching Python 2 int behavior on Python 2 (#1186) · cf0d0f9d
Pybind11's default conversion to int always produces a long on Python 2 (`int`s and `long`s were unified in Python 3). This patch fixes `int` handling to match Python 2 on Python 2; for short types (`size_t` or smaller), the number will be returned as an `int` if possible, otherwise `long`. Requires Python 2.5+. This is needed for things like `sys.exit`, which refuse to accept a `long`.
Henry Schreiner committed