Bug 2034174 - python-reportlab fails to build with Python 3.11: error: invalid use of incomplete typedef PyFrameObject {aka struct _frame}
Summary: python-reportlab fails to build with Python 3.11: error: invalid use of incom...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: python-reportlab
Version: 36
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Antonio T. sagitter
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.11
TreeView+ depends on / blocked
 
Reported: 2021-12-20 10:16 UTC by Tomáš Hrnčiar
Modified: 2022-06-22 11:49 UTC (History)
8 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2022-06-22 11:49:14 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Tomáš Hrnčiar 2021-12-20 10:16:34 UTC
python-reportlab fails to build with Python 3.11.0a3.

======================================================================
ERROR: test2 (test_graphics_render.RenderTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/reportlab-3.6.3/tests/test_graphics_render.py", line 155, in test2
    assert test(self.outDir) is None
           ^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/reportlab-3.6.3/tests/reportlab/graphics/renderPM.py", line 766, in test
    drawing.save(formats=['py','svg'],outDir=outDir,fnRoot=fnRoot)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/reportlab-3.6.3/tests/reportlab/graphics/shapes.py", line 796, in save
    f.write(asBytes(self._renderPy().replace('\n',os.linesep)))
                    ^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/reportlab-3.6.3/tests/reportlab/graphics/shapes.py", line 637, in _renderPy
    G = _renderGroupPy(self._explode(),'self',I)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/reportlab-3.6.3/tests/reportlab/graphics/shapes.py", line 563, in _renderGroupPy
    s = s + '%s%s.add(%s)\n' % (indent,pfx,_repr(n,I))
                                           ^^^^^^^^^^
  File "/builddir/build/BUILD/reportlab-3.6.3/tests/reportlab/graphics/shapes.py", line 524, in _repr
    from inspect import getargspec
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: cannot import name 'getargspec' from 'inspect' (/usr/lib64/python3.11/inspect.py)

======================================================================
ERROR: test4 (test_graphics_render.RenderTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/reportlab-3.6.3/tests/test_graphics_render.py", line 164, in test4
    FillModeDrawing(fillMode=fm).save(formats=formats,outDir=self.outDir,fnRoot='fillmode-'+('non-zero' if fm else 'even-odd'))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/reportlab-3.6.3/tests/reportlab/graphics/shapes.py", line 796, in save
    f.write(asBytes(self._renderPy().replace('\n',os.linesep)))
                    ^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/reportlab-3.6.3/tests/reportlab/graphics/shapes.py", line 637, in _renderPy
    G = _renderGroupPy(self._explode(),'self',I)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/reportlab-3.6.3/tests/reportlab/graphics/shapes.py", line 560, in _renderGroupPy
    s = s + _renderGroupPy(n,npfx,I,i,indent)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/reportlab-3.6.3/tests/reportlab/graphics/shapes.py", line 563, in _renderGroupPy
    s = s + '%s%s.add(%s)\n' % (indent,pfx,_repr(n,I))
                                           ^^^^^^^^^^
  File "/builddir/build/BUILD/reportlab-3.6.3/tests/reportlab/graphics/shapes.py", line 524, in _repr
    from inspect import getargspec
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: cannot import name 'getargspec' from 'inspect' (/usr/lib64/python3.11/inspect.py)

======================================================================
ERROR: test_axes (test_graphics_charts.ChartTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/reportlab-3.6.3/tests/test_graphics_charts.py", line 1062, in test_axes
    run_samples([(k,v,'axes') for k,v in locals().items() if k.lower().startswith('sample')])
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/reportlab-3.6.3/tests/test_graphics_charts.py", line 337, in run_samples
    d.save(formats=['pdf', 'gif', 'svg', 'ps', 'py']+eps(),outDir=outDir, fnRoot='test_graphics_charts_%s_%s' % (kind,k))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/reportlab-3.6.3/tests/reportlab/graphics/shapes.py", line 796, in save
    f.write(asBytes(self._renderPy().replace('\n',os.linesep)))
                    ^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/reportlab-3.6.3/tests/reportlab/graphics/shapes.py", line 637, in _renderPy
    G = _renderGroupPy(self._explode(),'self',I)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/reportlab-3.6.3/tests/reportlab/graphics/shapes.py", line 563, in _renderGroupPy
    s = s + '%s%s.add(%s)\n' % (indent,pfx,_repr(n,I))
                                           ^^^^^^^^^^
  File "/builddir/build/BUILD/reportlab-3.6.3/tests/reportlab/graphics/shapes.py", line 524, in _repr
    from inspect import getargspec
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: cannot import name 'getargspec' from 'inspect' (/usr/lib64/python3.11/inspect.py)

======================================================================
ERROR: test_legends (test_graphics_charts.ChartTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/reportlab-3.6.3/tests/test_graphics_charts.py", line 1175, in test_legends
    run_samples([(k,v,'legends') for k,v in locals().items() if k.lower().startswith('sample')])
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/reportlab-3.6.3/tests/test_graphics_charts.py", line 337, in run_samples
    d.save(formats=['pdf', 'gif', 'svg', 'ps', 'py']+eps(),outDir=outDir, fnRoot='test_graphics_charts_%s_%s' % (kind,k))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/reportlab-3.6.3/tests/reportlab/graphics/shapes.py", line 796, in save
    f.write(asBytes(self._renderPy().replace('\n',os.linesep)))
                    ^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/reportlab-3.6.3/tests/reportlab/graphics/shapes.py", line 637, in _renderPy
    G = _renderGroupPy(self._explode(),'self',I)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/reportlab-3.6.3/tests/reportlab/graphics/shapes.py", line 563, in _renderGroupPy
    s = s + '%s%s.add(%s)\n' % (indent,pfx,_repr(n,I))
                                           ^^^^^^^^^^
  File "/builddir/build/BUILD/reportlab-3.6.3/tests/reportlab/graphics/shapes.py", line 524, in _repr
    from inspect import getargspec
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: cannot import name 'getargspec' from 'inspect' (/usr/lib64/python3.11/inspect.py)

======================================================================
ERROR: tearDownClass (test_graphics_charts.ChartTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/reportlab-3.6.3/tests/test_graphics_charts.py", line 358, in tearDownClass
    run_samples([(k,v,'special') for k,v in globals().items() if k.lower().startswith('sample')
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/reportlab-3.6.3/tests/test_graphics_charts.py", line 337, in run_samples
    d.save(formats=['pdf', 'gif', 'svg', 'ps', 'py']+eps(),outDir=outDir, fnRoot='test_graphics_charts_%s_%s' % (kind,k))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/reportlab-3.6.3/tests/reportlab/graphics/shapes.py", line 796, in save
    f.write(asBytes(self._renderPy().replace('\n',os.linesep)))
                    ^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/reportlab-3.6.3/tests/reportlab/graphics/shapes.py", line 637, in _renderPy
    G = _renderGroupPy(self._explode(),'self',I)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/reportlab-3.6.3/tests/reportlab/graphics/shapes.py", line 563, in _renderGroupPy
    s = s + '%s%s.add(%s)\n' % (indent,pfx,_repr(n,I))
                                           ^^^^^^^^^^
  File "/builddir/build/BUILD/reportlab-3.6.3/tests/reportlab/graphics/shapes.py", line 524, in _repr
    from inspect import getargspec
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: cannot import name 'getargspec' from 'inspect' (/usr/lib64/python3.11/inspect.py)

----------------------------------------------------------------------
Ran 373 tests in 19.822s

FAILED (errors=5, skipped=5)

Removed from the inspect module:
    the getargspec function, deprecated since Python 3.0; use
    inspect.signature() or inspect.getfullargspec() instead.

https://bugs.python.org/issue45320
https://docs.python.org/3.11/whatsnew/3.11.html


https://docs.python.org/3.11/whatsnew/3.11.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.11/fedora-rawhide-x86_64/03054443-python-reportlab/

For all our attempts to build python-reportlab with Python 3.11, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.11/package/python-reportlab/

Testing and mass rebuild of packages is happening in copr. You can follow these instructions to test locally in mock if your package builds with Python 3.11:
https://copr.fedorainfracloud.org/coprs/g/python/python3.11/

Let us know here if you have any questions.

Python 3.11 is planned to be included in Fedora 37. To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.11.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires), so if this package is required a lot, it's important for us to get it fixed soon.
We'd appreciate help from the people who know this package best, but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Antonio T. sagitter 2021-12-31 13:21:03 UTC
This bug should have been fixed by latest 3.6.5 release in Rawhide branch now.

Comment 2 Ben Cotton 2022-02-08 21:17:51 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 36 development cycle.
Changing version to 36.

Comment 3 Tomáš Hrnčiar 2022-03-16 09:06:42 UTC
(In reply to Antonio T. sagitter from comment #1)
> This bug should have been fixed by latest 3.6.5 release in Rawhide branch
> now.

This was indeed fixed, but there is another error that occurred with Python 3.11.0a6. See traceback below.

src/rl_addons/rl_accel/_rl_accel.c:67:17: error: invalid use of incomplete typedef ‘PyFrameObject’ {aka ‘struct _frame’}
   67 |         py_frame->f_lineno = moduleLineno;
      |                 ^~
src/rl_addons/rl_accel/_rl_accel.c: In function ‘_a85_encode’:
src/rl_addons/rl_accel/_rl_accel.c:95:24: warning: pointer targets in assignment from ‘char *’ to ‘unsigned char *’ differ in signedness [-Wpointer-sign]
   95 |                 inData = PyBytes_AsString(_o1);
      |                        ^
src/rl_addons/rl_accel/_rl_accel.c:106:16: warning: pointer targets in assignment from ‘char *’ to ‘unsigned char *’ differ in signedness [-Wpointer-sign]
  106 |         inData = PyBytes_AsString(inObj);
      |                ^
src/rl_addons/rl_accel/_rl_accel.c: In function ‘_a85_decode’:
src/rl_addons/rl_accel/_rl_accel.c:195:24: warning: pointer targets in assignment from ‘char *’ to ‘unsigned char *’ differ in signedness [-Wpointer-sign]
  195 |                 inData = PyBytes_AsString(_o1);
      |                        ^
src/rl_addons/rl_accel/_rl_accel.c:206:16: warning: pointer targets in assignment from ‘char *’ to ‘unsigned char *’ differ in signedness [-Wpointer-sign]
  206 |         inData = PyBytes_AsString(inObj);
      |                ^
src/rl_addons/rl_accel/_rl_accel.c: In function ‘escapePDF’:
src/rl_addons/rl_accel/_rl_accel.c:413:24: warning: pointer targets in assignment from ‘char *’ to ‘unsigned char *’ differ in signedness [-Wpointer-sign]
  413 |                 inData = PyBytes_AsString(_o1);
      |                        ^
src/rl_addons/rl_accel/_rl_accel.c:424:16: warning: pointer targets in assignment from ‘char *’ to ‘unsigned char *’ differ in signedness [-Wpointer-sign]
  424 |         inData = PyBytes_AsString(inObj);
      |                ^
src/rl_addons/rl_accel/_rl_accel.c: In function ‘unicode2T1’:
src/rl_addons/rl_accel/_rl_accel.c:597:37: warning: passing argument 2 of ‘_GetStringBuf’ from incompatible pointer type [-Wincompatible-pointer-types]
  597 |         encObj = _GetStringBuf(_o2, &encStr);
      |                                     ^~~~~~~
      |                                     |
      |                                     char **
src/rl_addons/rl_accel/_rl_accel.c:545:60: note: expected ‘const char **’ but argument is of type ‘char **’
  545 | static PyObject *_GetStringBuf(PyObject *obj, const char **buf)
      |                                               ~~~~~~~~~~~~~^~~
src/rl_addons/rl_accel/_rl_accel.c: In function ‘instanceStringWidthTTF’:
src/rl_addons/rl_accel/_rl_accel.c:855:9: warning: ‘PyUnicode_WSTR_LENGTH’ is deprecated [-Wdeprecated-declarations]
  855 |         n = PyUnicode_GET_SIZE(text);
      |         ^
In file included from /usr/include/python3.11/unicodeobject.h:1042,
                 from /usr/include/python3.11/Python.h:51,
                 from src/rl_addons/rl_accel/_rl_accel.c:9:
/usr/include/python3.11/cpython/unicodeobject.h:437:26: note: declared here
  437 | static inline Py_ssize_t PyUnicode_WSTR_LENGTH(PyObject *op) {
      |                          ^~~~~~~~~~~~~~~~~~~~~
src/rl_addons/rl_accel/_rl_accel.c:855:9: warning: ‘PyUnicode_AsUnicode’ is deprecated [-Wdeprecated-declarations]
  855 |         n = PyUnicode_GET_SIZE(text);
      |         ^
/usr/include/python3.11/cpython/unicodeobject.h:571:45: note: declared here
  571 | Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode(
      |                                             ^~~~~~~~~~~~~~~~~~~
src/rl_addons/rl_accel/_rl_accel.c:855:9: warning: ‘PyUnicode_WSTR_LENGTH’ is deprecated [-Wdeprecated-declarations]
  855 |         n = PyUnicode_GET_SIZE(text);
      |         ^
/usr/include/python3.11/cpython/unicodeobject.h:437:26: note: declared here
  437 | static inline Py_ssize_t PyUnicode_WSTR_LENGTH(PyObject *op) {
      |                          ^~~~~~~~~~~~~~~~~~~~~
src/rl_addons/rl_accel/_rl_accel.c:856:9: warning: ‘PyUnicode_AsUnicode’ is deprecated [-Wdeprecated-declarations]
  856 |         b = PyUnicode_AS_UNICODE(text);
      |         ^
/usr/include/python3.11/cpython/unicodeobject.h:571:45: note: declared here
  571 | Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode(
      |                                             ^~~~~~~~~~~~~~~~~~~
error: command '/usr/bin/gcc' failed with exit code 1

The PyFrameObject structure member has been moved to the internal C API headers.

While the documentation notes that the PyFrameObject fields are subject to change at any time, they have been stable for a long time and were used in several popular extensions.

In Python 3.11, the frame struct was reorganized to allow performance optimizations. Some fields were removed entirely, as they were details of the old implementation.

PyFrameObject fields:
    f_back: use PyFrame_GetBack().
    f_blockstack: removed.
    f_builtins: use PyObject_GetAttrString((PyObject*)frame, "f_builtins").
    f_code: use PyFrame_GetCode().
    f_gen: removed.
    f_globals: use PyObject_GetAttrString((PyObject*)frame, "f_globals").
    f_iblock: removed.
    f_lasti: use PyObject_GetAttrString((PyObject*)frame, "f_lasti"). Code using f_lasti with PyCode_Addr2Line() must use PyFrame_GetLineNumber() instead.
    f_lineno: use PyFrame_GetLineNumber()
    f_locals: use PyObject_GetAttrString((PyObject*)frame, "f_locals").
    f_stackdepth: removed.
    f_state: no public API (renamed to f_frame.f_state).
    f_trace: no public API.
    f_trace_lines: use PyObject_GetAttrString((PyObject*)frame, "f_trace_lines") (it also be modified).
    f_trace_opcodes: use PyObject_GetAttrString((PyObject*)frame, "f_trace_opcodes") (it also be modified).
    f_localsplus: no public API (renamed to f_frame.localsplus).
    f_valuestack: removed.

The Python frame object is now created lazily. A side effect is that the f_back member must not be accessed directly, since its value is now also computed lazily. The PyFrame_GetBack() function must be called instead.

Comment 4 Miro Hrončok 2022-06-22 11:49:14 UTC
Closing this in bulk as it built with Python 3.11. If this needs to remain open for a followup, feel free to reopen, I won't close in bulk again.


Note You need to log in before you can comment on or make changes to this bug.