pr5210,5211-switch-from-deprecated-functions.patch 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. https://github.com/cython/cython/pull/5210
  2. https://github.com/cython/cython/pull/5211
  3. --- contrib/tools/cython/Cython/Utility/Embed.c (19fe9379d5dd7e26afd2405b1890080712d1892c)
  4. +++ contrib/tools/cython/Cython/Utility/Embed.c (bdf71953ac311b76dcfb2ffd7ec4b71a018ed416)
  5. @@ -28,6 +28,7 @@ static int __Pyx_main(int argc, wchar_t **argv) {
  6. m = fpgetmask();
  7. fpsetmask(m & ~FP_X_OFL);
  8. #endif
  9. +#if PY_VERSION_HEX < 0x03080000
  10. if (argc && argv) {
  11. Py_InitArgcArgv(argc, argv);
  12. Py_SetProgramName(argv[0]);
  13. @@ -35,6 +36,38 @@ static int __Pyx_main(int argc, wchar_t **argv) {
  14. Py_Initialize();
  15. if (argc && argv)
  16. PySys_SetArgv(argc, argv);
  17. +#else
  18. + {
  19. + PyStatus status;
  20. +
  21. + PyConfig config;
  22. + PyConfig_InitPythonConfig(&config);
  23. + // Disable parsing command line arguments
  24. + config.parse_argv = 0;
  25. +
  26. + if (argc && argv) {
  27. + status = PyConfig_SetString(&config, &config.program_name, argv[0]);
  28. + if (PyStatus_Exception(status)) {
  29. + PyConfig_Clear(&config);
  30. + return 1;
  31. + }
  32. +
  33. + status = PyConfig_SetArgv(&config, argc, argv);
  34. + if (PyStatus_Exception(status)) {
  35. + PyConfig_Clear(&config);
  36. + return 1;
  37. + }
  38. + }
  39. +
  40. + status = Py_InitializeFromConfig(&config);
  41. + if (PyStatus_Exception(status)) {
  42. + PyConfig_Clear(&config);
  43. + return 1;
  44. + }
  45. +
  46. + PyConfig_Clear(&config);
  47. + }
  48. +#endif
  49. { /* init module '%(module_name)s' as '__main__' */
  50. PyObject* m = NULL;
  51. %(module_is_main)s = 1;