wxPython4: patch for Python 3.11

This commit is contained in:
Đoàn Trần Công Danh 2022-09-25 09:49:21 +07:00
parent f6a6bb7415
commit 84e841bd95
3 changed files with 125 additions and 1 deletions

View File

@ -0,0 +1,84 @@
Index: wxPython-4.0.7/bin/.waf3/waflib/ConfigSet.py
===================================================================
--- wxPython-4.0.7.orig/bin/.waf3/waflib/ConfigSet.py
+++ wxPython-4.0.7/bin/.waf3/waflib/ConfigSet.py
@@ -146,7 +146,7 @@ class ConfigSet(object):
Utils.writef(filename,''.join(buf))
def load(self,filename):
tbl=self.table
- code=Utils.readf(filename,m='rU')
+ code=Utils.readf(filename,m='r')
for m in re_imp.finditer(code):
g=m.group
tbl[g(2)]=eval(g(3))
Index: wxPython-4.0.7/bin/.waf3/waflib/Context.py
===================================================================
--- wxPython-4.0.7.orig/bin/.waf3/waflib/Context.py
+++ wxPython-4.0.7/bin/.waf3/waflib/Context.py
@@ -106,7 +106,7 @@ class Context(ctx):
cache[node]=True
self.pre_recurse(node)
try:
- function_code=node.read('rU',encoding)
+ function_code=node.read('r',encoding)
exec(compile(function_code,node.abspath(),'exec'),self.exec_dict)
finally:
self.post_recurse(node)
@@ -346,7 +346,7 @@ def load_module(path,encoding=None):
pass
module=imp.new_module(WSCRIPT_FILE)
try:
- code=Utils.readf(path,m='rU',encoding=encoding)
+ code=Utils.readf(path,m='r',encoding=encoding)
except EnvironmentError:
raise Errors.WafError('Could not read the file %r'%path)
module_dir=os.path.dirname(path)
Index: wxPython-4.0.7/sip/siplib/sip.h
===================================================================
--- wxPython-4.0.7.orig/sip/siplib/sip.h
+++ wxPython-4.0.7/sip/siplib/sip.h
@@ -1794,7 +1794,7 @@ typedef struct _sipAPIDef {
int (*api_get_time)(PyObject *, sipTimeDef *);
PyObject *(*api_from_time)(const sipTimeDef *);
int (*api_is_user_type)(const sipWrapperType *);
- struct _frame *(*api_get_frame)(int);
+ PyFrameObject *(*api_get_frame)(int);
int (*api_check_plugin_for_type)(const sipTypeDef *, const char *);
PyObject *(*api_unicode_new)(SIP_SSIZE_T, unsigned, int *, void **);
void (*api_unicode_write)(int, void *, int, unsigned);
Index: wxPython-4.0.7/sip/siplib/siplib.c
===================================================================
--- wxPython-4.0.7.orig/sip/siplib/siplib.c
+++ wxPython-4.0.7/sip/siplib/siplib.c
@@ -439,7 +439,7 @@ static PyObject *sip_api_from_datetime(c
static int sip_api_get_time(PyObject *obj, sipTimeDef *time);
static PyObject *sip_api_from_time(const sipTimeDef *time);
static int sip_api_is_user_type(const sipWrapperType *wt);
-static struct _frame *sip_api_get_frame(int);
+static PyFrameObject *sip_api_get_frame(int);
static int sip_api_check_plugin_for_type(const sipTypeDef *td,
const char *name);
static PyObject *sip_api_unicode_new(SIP_SSIZE_T len, unsigned maxchar,
@@ -13688,15 +13688,19 @@ static int sip_api_is_user_type(const si
/*
* Return a frame from the execution stack.
*/
-static struct _frame *sip_api_get_frame(int depth)
+static PyFrameObject *sip_api_get_frame(int depth)
{
- struct _frame *frame = PyEval_GetFrame();
+ PyFrameObject *frame = PyEval_GetFrame();
+ Py_XINCREF(frame);
while (frame != NULL && depth > 0)
{
- frame = frame->f_back;
+ PyFrameObject *oframe = frame;
+ frame = PyFrame_GetBack(frame);
+ Py_DECREF(oframe);
--depth;
}
+ Py_XDECREF(frame);
return frame;
}

View File

@ -0,0 +1,32 @@
Index: wxPython-4.0.7/wx/lib/masked/maskededit.py
===================================================================
--- wxPython-4.0.7.orig/wx/lib/masked/maskededit.py
+++ wxPython-4.0.7/wx/lib/masked/maskededit.py
@@ -2645,7 +2645,7 @@ class MaskedEditMixin:
raise ve
elif replace_to > end:
#### dbg(indent=0)
- ve = ValueError('"%s" will not fit into field %d of control "%s"' (choice, index, self.name))
+ ve = ValueError('"%s" will not fit into field %d of control "%s"' % (choice, index, self.name))
ve.value = choice
ve.index = index
raise ve
Index: wxPython-4.0.7/wx/lib/plot/plotcanvas.py
===================================================================
--- wxPython-4.0.7.orig/wx/lib/plot/plotcanvas.py
+++ wxPython-4.0.7/wx/lib/plot/plotcanvas.py
@@ -1852,12 +1852,12 @@ class PlotCanvas(wx.Panel):
# Get ticks and textExtents for axis if required
xticks = yticks = None
xTextExtent = yTextExtent = (0, 0) # No text for ticks
- if self._xSpec is not 'none':
+ if self._xSpec != 'none':
xticks = self._xticks(xAxis[0], xAxis[1])
# w h of x axis text last number on axis
xTextExtent = dc.GetTextExtent(xticks[-1][1])
- if self._ySpec is not 'none':
+ if self._ySpec != 'none':
yticks = self._yticks(yAxis[0], yAxis[1])
if self.logScale[1]:
# make sure we have enough room to display SI notation.

View File

@ -1,7 +1,7 @@
# Template file for 'wxPython4'
pkgname=wxPython4
version=4.0.7
revision=4
revision=5
wrksrc="wxPython-${version}"
build_style=python3-module
make_build_args="--skip-build"
@ -21,6 +21,14 @@ if [ "$CROSS_BUILD" ]; then
CFLAGS="-I${XBPS_CROSS_BASE}/${py3_inc} -I${XBPS_CROSS_BASE}/usr/include"
fi
post_extract() {
# need to patch for Python 3.11, extract them now.
cd bin
sed '/__name__.*__main__/i sys.exit(0)' waf-* >tmp-waf
python3 tmp-waf
ln -s .waf3-* .waf3
}
pre_build() {
chmod -R go+rX $wrksrc
if [ "$CROSS_BUILD" ]; then