Changeset: 182ad5c3612f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/182ad5c3612f
Branch: default
Log Message:

Merge with Sep2022 branch.


diffs (74 lines):

diff --git a/monetdb5/modules/atoms/url.c b/monetdb5/modules/atoms/url.c
--- a/monetdb5/modules/atoms/url.c
+++ b/monetdb5/modules/atoms/url.c
@@ -948,7 +948,7 @@ BATextractURLHost(bat *res, const bat *b
                                        if (l > 0) {
                                                // if ((msg = 
str_Sub_String(&buf, &buflen, host, 0, l)) != MAL_SUCCEED)
                                                //      break;
-                                               if ((msg = str_buf_copy(&buf, 
&buflen, host, (size_t) l)) != MAL_SUCCEED)
+                                               if ((msg = str_buf_copy(&buf, 
&buflen, host, (size_t) (l + 1))) != MAL_SUCCEED)
                                                        break;
                                                if (bunfastapp_nocheckVAR(bn, 
buf) != GDK_SUCCEED) {
                                                        msg = 
createException(MAL, "baturl.extractURLHost", SQLSTATE(HY013) MAL_MALLOC_FAIL );
diff --git a/sql/backends/monet5/UDF/pyapi3/pyapi3.c 
b/sql/backends/monet5/UDF/pyapi3/pyapi3.c
--- a/sql/backends/monet5/UDF/pyapi3/pyapi3.c
+++ b/sql/backends/monet5/UDF/pyapi3/pyapi3.c
@@ -1379,6 +1379,9 @@ wrapup:
        return msg;
 }
 
+#ifdef _MSC_VER
+#define wcsdup _wcsdup
+#endif
 static str
 PYAPI3PyAPIprelude(void) {
        MT_lock_set(&pyapiLock);
@@ -1393,23 +1396,38 @@ PYAPI3PyAPIprelude(void) {
                /* introduced in 3.8, we use it for 3.9 and later */
                PyStatus status;
                PyConfig config;
+               wchar_t *pyhome = NULL;
 
-               PyConfig_InitPythonConfig(&config);
-               config.isolated = 1;
+               /* first figure out where Python was installed */
+               PyConfig_InitIsolatedConfig(&config);
+               status = PyConfig_Read(&config);
+               if (!PyStatus_Exception(status))
+                       pyhome = wcsdup(config.prefix);
+               PyConfig_Clear(&config);
+               /* now really configure the Python subsystem, using the Python
+                * prefix directory as its home
+                * if we don't set config.home, sys.path will not be set
+                * correctly on Windows and initialization will fail */
+               PyConfig_InitIsolatedConfig(&config);
                status = PyConfig_SetArgv(&config, 1, argv);
+               if (!PyStatus_Exception(status))
+                       status = PyConfig_SetString(&config, &config.home, 
pyhome);
+               free(pyhome);
+               if (!PyStatus_Exception(status))
+                       status = PyConfig_Read(&config);
+               if (!PyStatus_Exception(status))
+                       status = Py_InitializeFromConfig(&config);
+               PyConfig_Clear(&config);
                if (PyStatus_Exception(status)) {
                        MT_lock_unset(&pyapiLock);
-                       throw(MAL, "pyapi3.eval", SQLSTATE(PY000) "Python 
initialization failed.");
+                       throw(MAL, "pyapi3.eval",
+                                 SQLSTATE(PY000) "Python initialization 
failed: %s: %s",
+                                 status.func ? status.func : 
"PYAPI3PyAPIprelude",
+                                 status.err_msg ? status.err_msg : "");
                }
-               status = Py_InitializeFromConfig(&config);
-               if (PyStatus_Exception(status)) {
-                       MT_lock_unset(&pyapiLock);
-                       throw(MAL, "pyapi3.eval", SQLSTATE(PY000) "Python 
initialization failed.");
-               }
-               PyConfig_Clear(&config);
 #else
                /* PySys_SetArgvEx deprecated in 3.11 */
-               Py_Initialize();
+               Py_InitializeEx(0);
                PySys_SetArgvEx(1, argv, 0);
 #endif
 
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to