diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 984c69b..b6f879b 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -42,6 +42,8 @@ jobs: sudo sh -c "echo 'extension=phpy.so' > /etc/php/${PHP_VERSION}/cli/conf.d/90-phpy.ini" php --ri phpy - name: Run phpunit tests + env: + LC_ALL: POSIX # Do not remove this line, PR: https://github.com/swoole/phpy/pull/45 run: | composer install composer test diff --git a/src/php/core.cc b/src/php/core.cc index 9521601..c9e0dae 100644 --- a/src/php/core.cc +++ b/src/php/core.cc @@ -211,7 +211,19 @@ PHP_MINIT_FUNCTION(phpy) { return FAILURE; } srand(time(NULL)); + +#if PY_VERSION_HEX >= 0x03080000 + // doc: https://docs.python.org/3/c-api/init_config.html + PyConfig py_config; + PyConfig_InitPythonConfig(&py_config); + py_config.install_signal_handlers = 0; // ignore signal + py_config.parse_argv = 0; + Py_InitializeFromConfig(&py_config); + PyConfig_Clear(&py_config); +#else Py_InitializeEx(0); +#endif + module_phpy = PyImport_ImportModule("phpy"); if (!module_phpy) { PyErr_Print(); diff --git a/tests/phpunit/LocaleTest.php b/tests/phpunit/LocaleTest.php new file mode 100644 index 0000000..3fed9cd --- /dev/null +++ b/tests/phpunit/LocaleTest.php @@ -0,0 +1,31 @@ +assertEquals(sprintf("%s\n%s\n%s\n%s\n", $locale->getdefaultlocale(), $locale->getpreferredencoding(), $sys->getdefaultencoding(), $sys->getfilesystemencoding()), $result); + } +}