|
158 | 158 | #define PYBIND11_BYTES_SIZE PyBytes_Size
|
159 | 159 | #define PYBIND11_LONG_CHECK(o) PyLong_Check(o)
|
160 | 160 | #define PYBIND11_LONG_AS_LONGLONG(o) PyLong_AsLongLong(o)
|
| 161 | +#define PYBIND11_LONG_FROM_SIGNED(o) PyLong_FromSsize_t((ssize_t) o) |
| 162 | +#define PYBIND11_LONG_FROM_UNSIGNED(o) PyLong_FromSize_t((size_t) o) |
161 | 163 | #define PYBIND11_BYTES_NAME "bytes"
|
162 | 164 | #define PYBIND11_STRING_NAME "str"
|
163 | 165 | #define PYBIND11_SLICE_OBJECT PyObject
|
|
180 | 182 | #define PYBIND11_BYTES_SIZE PyString_Size
|
181 | 183 | #define PYBIND11_LONG_CHECK(o) (PyInt_Check(o) || PyLong_Check(o))
|
182 | 184 | #define PYBIND11_LONG_AS_LONGLONG(o) (PyInt_Check(o) ? (long long) PyLong_AsLong(o) : PyLong_AsLongLong(o))
|
| 185 | +#define PYBIND11_LONG_FROM_SIGNED(o) PyInt_FromSsize_t((ssize_t) o) // Returns long if needed. |
| 186 | +#define PYBIND11_LONG_FROM_UNSIGNED(o) PyInt_FromSize_t((size_t) o) // Returns long if needed. |
183 | 187 | #define PYBIND11_BYTES_NAME "str"
|
184 | 188 | #define PYBIND11_STRING_NAME "unicode"
|
185 | 189 | #define PYBIND11_SLICE_OBJECT PySliceObject
|
@@ -803,9 +807,13 @@ template <typename T> struct format_descriptor<T, detail::enable_if_t<std::is_ar
|
803 | 807 | static std::string format() { return std::string(1, c); }
|
804 | 808 | };
|
805 | 809 |
|
| 810 | +#if !defined(PYBIND11_CPP17) |
| 811 | + |
806 | 812 | template <typename T> constexpr const char format_descriptor<
|
807 | 813 | T, detail::enable_if_t<std::is_arithmetic<T>::value>>::value[2];
|
808 | 814 |
|
| 815 | +#endif |
| 816 | + |
809 | 817 | /// RAII wrapper that temporarily clears any Python error state
|
810 | 818 | struct error_scope {
|
811 | 819 | PyObject *type, *value, *trace;
|
|
0 commit comments