Jump to content


Beeker

Member Since 10 Jan 2009
Offline Last Active Today, 14:49
-----

Posts I've Made

In Topic: merge requests for PLi's git

6 January 2024 - 23:44

I had to patch Python3 to suppress the error.

diff --git a/Python/getargs.c b/Python/getargs.c
index 066739f..e85b116 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -426,6 +426,7 @@ vgetargs1(PyObject *args, const char *format, va_list *p_va, int flags)
 
         stack = _PyTuple_ITEMS(args);
         nargs = PyTuple_GET_SIZE(args);
+        flags = FLAG_SIZE_T;
     }
     else {
         stack = NULL;

Problem:

The flags variable remains 0 in the whole function call chain unconditional (getsargs.c file).

PyArg_ParseTuple() (defined as 0)- > vgetargs1() -> vgetargs1_impl() - convertitem() -> convertsimple().

The only change in value is:

flags = flags & ~FLAG_COMPAT;

But that doesn't changes the value if flags is 0.

And finally always ends up  in the error, defined as macro in convertsimple().

#define REQUIRE_PY_SSIZE_T_CLEAN \
    if (!(flags & FLAG_SIZE_T)) { \
        PyErr_SetString(PyExc_SystemError, \
                        "PY_SSIZE_T_CLEAN macro must be defined for '#' formats"); \
        RETURN_ERR_OCCURRED; \
    }

Or I overlooked something?


In Topic: merge requests for PLi's git

6 January 2024 - 23:15

confirmed.

Do you have a working patch?

 

Because this doesn't work with Python 3.12.1 (and with older versions either?).

diff --git a/lib/base/estring.cpp b/lib/base/estring.cpp
index 709d120e7..c12a40a38 100644
--- a/lib/base/estring.cpp
+++ b/lib/base/estring.cpp
@@ -11,6 +11,8 @@
 #include "freesatv2.h"
 #include "big5.h"
 #include "gb18030.h"
+
+#define PY_SSIZE_T_CLEAN
 #include <Python.h>
 
 std::string buildShortName( const std::string &str )
diff --git a/lib/python/python.h b/lib/python/python.h
index e3259407a..dff68ecc7 100644
--- a/lib/python/python.h
+++ b/lib/python/python.h
@@ -6,6 +6,8 @@
 
 #include <string>
 #include <lib/base/object.h>
+
+#define PY_SSIZE_T_CLEAN
 #include "Python.h"
 
 #if !defined(SKIP_PART1) && !defined(SWIG)
diff --git a/lib/python/python_console.i b/lib/python/python_console.i
index 1591570d2..5bb148f83 100644
--- a/lib/python/python_console.i
+++ b/lib/python/python_console.i
@@ -187,7 +187,7 @@ static PyObject *
 eConsolePy_write(eConsolePy* self, PyObject *args)
 {
 	char *data;
-	int data_len;
+	Py_ssize_t data_len;
 	int len = -1;
 	if (!PyArg_ParseTuple(args, "s#|i", &data, &data_len, &len))
 	{

And I've tried many more.


In Topic: plugin Het weer

29 November 2023 - 17:53

Ja graag, bedankt.


In Topic: plugin Het weer

29 November 2023 - 16:59

Fix sneeuw radar

 

https://github.com/E...HetWeer/pull/29


In Topic: plugin Het weer

29 November 2023 - 16:43

Fix onderweg.