py3k.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef PyOpenSSL_PY3K_H_
  2. #define PyOpenSSL_PY3K_H_
  3. #if (PY_VERSION_HEX >= 0x03000000)
  4. #define PY3
  5. #define PyOpenSSL_MODINIT(name) \
  6. PyMODINIT_FUNC \
  7. PyInit_##name(void)
  8. #define PyText_CheckExact PyUnicode_CheckExact
  9. #define PyText_FromString PyUnicode_FromString
  10. #define PyText_FromStringAndSize PyUnicode_FromStringAndSize
  11. #define PyOpenSSL_HEAD_INIT(type, size) PyVarObject_HEAD_INIT(NULL, size)
  12. #define PyOpenSSL_Integer_Check(o) PyLong_Check(o)
  13. #define PyOpenSSL_MODRETURN(module) { return module; }
  14. #define BYTESTRING_FMT "y"
  15. #else /* (PY_VERSION_HEX >= 0x03000000) */
  16. #define PyOpenSSL_MODRETURN(module) { return; }
  17. #define PyOpenSSL_HEAD_INIT(type, size) PyObject_HEAD_INIT(NULL) 0,
  18. #define PyBytes_FromStringAndSize PyString_FromStringAndSize
  19. #define PyOpenSSL_Integer_Check(o) (PyInt_Check(o) || PyLong_Check(o))
  20. #define PyBytes_Size PyString_Size
  21. #define PyBytes_Check PyString_Check
  22. #define PyBytes_CheckExact PyString_CheckExact
  23. #define PyBytes_AsString PyString_AsString
  24. #define PyBytes_FromString PyString_FromString
  25. #define PyBytes_FromStringAndSize PyString_FromStringAndSize
  26. #define _PyBytes_Resize _PyString_Resize
  27. #define PyText_CheckExact PyString_CheckExact
  28. #define PyText_FromString PyString_FromString
  29. #define PyText_FromStringAndSize PyString_FromStringAndSize
  30. #define PyOpenSSL_MODINIT(name) \
  31. void \
  32. init##name(void)
  33. #define BYTESTRING_FMT "s"
  34. #endif /* (PY_VERSION_HEX >= 0x03000000) */
  35. #endif /* PyOpenSSL_PY3K_H_ */