fix-python-2.patch 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. --- contrib/libs/pybind11/include/pybind11/detail/class.h (index)
  2. +++ contrib/libs/pybind11/include/pybind11/detail/class.h (working tree)
  3. @@ -628,6 +628,9 @@ extern "C" inline int pybind11_getbuffer(PyObject *obj, Py_buffer *view, int fla
  4. return -1;
  5. }
  6. std::memset(view, 0, sizeof(Py_buffer));
  7. +#if PY_MAJOR_VERSION < 3
  8. + buffer_info *info = tinfo->get_buffer(obj, tinfo->get_buffer_data);
  9. +#else
  10. buffer_info *info = nullptr;
  11. try {
  12. info = tinfo->get_buffer(obj, tinfo->get_buffer_data);
  13. @@ -639,6 +642,7 @@ extern "C" inline int pybind11_getbuffer(PyObject *obj, Py_buffer *view, int fla
  14. if (info == nullptr) {
  15. pybind11_fail("FATAL UNEXPECTED SITUATION: tinfo->get_buffer() returned nullptr.");
  16. }
  17. +#endif
  18. if ((flags & PyBUF_WRITABLE) == PyBUF_WRITABLE && info->readonly) {
  19. delete info;
  20. --- contrib/libs/pybind11/include/pybind11/detail/type_caster_base.h (index)
  21. +++ contrib/libs/pybind11/include/pybind11/detail/type_caster_base.h (working tree)
  22. @@ -12,7 +12,9 @@
  23. #include <pybind11/pytypes.h>
  24. #include "common.h"
  25. +#if PY_MAJOR_VERSION >= 3
  26. #include "cpp_conduit.h"
  27. +#endif
  28. #include "descr.h"
  29. #include "internals.h"
  30. #include "typeid.h"
  31. @@ -624,6 +626,7 @@ public:
  32. }
  33. return false;
  34. }
  35. +#if PY_MAJOR_VERSION >= 3
  36. bool try_cpp_conduit(handle src) {
  37. value = try_raw_pointer_ephemeral_from_cpp_conduit(src, cpptype);
  38. if (value != nullptr) {
  39. @@ -631,6 +634,7 @@ public:
  40. }
  41. return false;
  42. }
  43. +#endif
  44. void check_holder_compat() {}
  45. PYBIND11_NOINLINE static void *local_load(PyObject *src, const type_info *ti) {
  46. @@ -762,9 +766,11 @@ public:
  47. return true;
  48. }
  49. +#if PY_MAJOR_VERSION >= 3
  50. if (convert && cpptype && this_.try_cpp_conduit(src)) {
  51. return true;
  52. }
  53. +#endif
  54. return false;
  55. }