Bug 2208498 - python-pikepdf fails to build with Python 3.12: AttributeError: stream_dict
Summary: python-pikepdf fails to build with Python 3.12: AttributeError: stream_dict
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: python-pikepdf
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Elliott Sales de Andrade
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.12
TreeView+ depends on / blocked
 
Reported: 2023-05-19 09:34 UTC by Tomáš Hrnčiar
Modified: 2023-07-30 04:52 UTC (History)
6 users (show)

Fixed In Version: python-pikepdf-8.2.2-1.fc39
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-07-30 04:52:44 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Tomáš Hrnčiar 2023-05-19 09:34:25 UTC
python-pikepdf fails to build with Python 3.12.0a7.

=================================== FAILURES ===================================
____________________________ test_get_equality_dict ____________________________
[gw0] linux -- Python 3.12.0 /usr/bin/python3

congress = (<[PdfError('/builddir/build/BUILD/pikepdf-7.2.0/tests/resources/congress.pdf (offset 743): getStreamData called on un...bject at 0x7fa7d50ae0f0>, <pikepdf.Pdf description='/builddir/build/BUILD/pikepdf-7.2.0/tests/resources/congress.pdf'>)

    def test_get_equality_dict(congress):
        page = congress[1].pages[0]
    
        assert page.MediaBox == page['/MediaBox'] == page.get('/MediaBox')
    
        with pytest.raises(RuntimeError):
>           page.stream_dict

tests/test_dictionary.py:39: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pikepdf.Page({
  "/Contents": pikepdf.Stream(owner=<...>, data=b'q\n200.0000 0 0 304.0'..., {
    "/Length": 50
  }),...   "/Subtype": "/Image",
        "/Type": "/XObject",
        "/Width": 1000
      })
    }
  },
  "/Type": "/Page"
})>
name = 'stream_dict'

    def __getattr__(self, name):
>       return getattr(self.obj, name)
E       AttributeError: stream_dict

../../BUILDROOT/python-pikepdf-7.2.0-1.fc39.x86_64/usr/lib64/python3.12/site-packages/pikepdf/_methods.py:1174: AttributeError
_______________________________ test_stack_depth _______________________________
[gw0] linux -- Python 3.12.0 /usr/bin/python3

    @skip_if_pypy
    def test_stack_depth():
        a = [42]
        for _ in range(100):
            a = [a]
        rlimit = sys.getrecursionlimit()
        try:
            sys.setrecursionlimit(100)
>           with pytest.raises(RecursionError):
E           Failed: DID NOT RAISE <class 'RecursionError'>

tests/test_object.py:139: Failed
_____________ TestAddResource.test_resources_exists_but_wrong_type _____________
[gw0] linux -- Python 3.12.0 /usr/bin/python3

self = <test_page.TestAddResource object at 0x7fa7d56d1250>
graph_page = <pikepdf.Page({
  "/Contents": pikepdf.Stream(owner=<...>, data=b'q\n545.280000 0 0 443'..., {
    "/Length": 44
  }),...545.2800'), Decimal('443.5200') ],
  "/Parent": <reference to /Pages>,
  "/Resources": "/Dummy",
  "/Type": "/Page"
})>

    def test_resources_exists_but_wrong_type(self, graph_page):
        d = self._make_simple_dict()
    
        del graph_page.obj.Resources
        graph_page.obj.Resources = Name.Dummy
        with pytest.raises(TypeError, match='exists but is not a dictionary'):
>           graph_page.add_resource(d, Name.XObject, Name.Im0, replace_existing=False)

tests/test_page.py:101: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../BUILDROOT/python-pikepdf-7.2.0-1.fc39.x86_64/usr/lib64/python3.12/site-packages/pikepdf/_methods.py:1000: in add_resource
    resources = self.resources

...

../../BUILDROOT/python-pikepdf-7.2.0-1.fc39.x86_64/usr/lib64/python3.12/site-packages/pikepdf/_methods.py:1174: in __getattr__
    return getattr(self.obj, name)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pikepdf.Page({
  "/Contents": pikepdf.Stream(owner=<...>, data=b'q\n545.280000 0 0 443'..., {
    "/Length": 44
  }),...545.2800'), Decimal('443.5200') ],
  "/Parent": <reference to /Pages>,
  "/Resources": "/Dummy",
  "/Type": "/Page"
})>
name = 'obj'

    def __getattr__(self, name):
>       return getattr(self.obj, name)
E       AttributeError: obj

../../BUILDROOT/python-pikepdf-7.2.0-1.fc39.x86_64/usr/lib64/python3.12/site-packages/pikepdf/_methods.py:1174: AttributeError
_____________________________ test_unattached_page _____________________________
[gw1] linux -- Python 3.12.0 /usr/bin/python3

    def test_unattached_page():
        rawpage = Dictionary(
            Type=Name.Page, MediaBox=[0, 0, 612, 792], Resources=Dictionary()
        )
        page = Page(rawpage)
    
        with pytest.raises(ValueError, match='not attached'):
>           page.index

tests/test_pages.py:512: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../BUILDROOT/python-pikepdf-7.2.0-1.fc39.x86_64/usr/lib64/python3.12/site-packages/pikepdf/_methods.py:1174: in __getattr__
    return getattr(self.obj, name)

...

../../BUILDROOT/python-pikepdf-7.2.0-1.fc39.x86_64/usr/lib64/python3.12/site-packages/pikepdf/_methods.py:1174: in __getattr__
    return getattr(self.obj, name)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = pikepdf.Page({
  "/MediaBox": [ 0, 0, 612, 792 ],
  "/Resources": {

  },
  "/Type": "/Page"
})
name = 'obj'

    def __getattr__(self, name):
>       return getattr(self.obj, name)
E       AttributeError: obj

../../BUILDROOT/python-pikepdf-7.2.0-1.fc39.x86_64/usr/lib64/python3.12/site-packages/pikepdf/_methods.py:1174: AttributeError
_____________________________ test_unindexed_page ______________________________
[gw1] linux -- Python 3.12.0 /usr/bin/python3

graph = <pikepdf.Pdf description='/builddir/build/BUILD/pikepdf-7.2.0/tests/resources/graph.pdf'>

    def test_unindexed_page(graph):
        page = graph.pages[0]
        del graph.pages[0]
        with pytest.raises(ValueError, match='not consistently registered'):
>           page.index

tests/test_pages.py:521: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../BUILDROOT/python-pikepdf-7.2.0-1.fc39.x86_64/usr/lib64/python3.12/site-packages/pikepdf/_methods.py:1174: in __getattr__
    return getattr(self.obj, name)

...

../../BUILDROOT/python-pikepdf-7.2.0-1.fc39.x86_64/usr/lib64/python3.12/site-packages/pikepdf/_methods.py:1174: in __getattr__
    return getattr(self.obj, name)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pikepdf.Page({
  "/Contents": pikepdf.Stream(owner=<...>, data=b'q\n545.280000 0 0 443'..., {
    "/Length": 44
  }),...   "/Subtype": "/Image",
        "/Type": "/XObject",
        "/Width": 2272
      })
    }
  },
  "/Type": "/Page"
})>
name = 'obj'

    def __getattr__(self, name):
>       return getattr(self.obj, name)
E       AttributeError: obj

../../BUILDROOT/python-pikepdf-7.2.0-1.fc39.x86_64/usr/lib64/python3.12/site-packages/pikepdf/_methods.py:1174: AttributeError
=============================== warnings summary ===============================
tests/test_page.py::TestAddResource::test_resources_exists_but_wrong_type
  /usr/lib/python3.12/site-packages/_pytest/unraisableexception.py:78: PytestUnraisableExceptionWarning: Exception ignored in garbage collection: None
  
  Traceback (most recent call last):
    File "/builddir/build/BUILDROOT/python-pikepdf-7.2.0-1.fc39.x86_64/usr/lib64/python3.12/site-packages/pikepdf/_methods.py", line 956, in resources
      raise TypeError("Page /Resources exists but is not a dictionary")
  TypeError: Page /Resources exists but is not a dictionary
  
  The above exception was the direct cause of the following exception:
  
  SystemError: <built-in method  of PyCapsule object at 0x7fa7d7866430> returned a result with an exception set
  
...
  
  The above exception was the direct cause of the following exception:
  
  Traceback (most recent call last):
    File "/builddir/build/BUILDROOT/python-pikepdf-7.2.0-1.fc39.x86_64/usr/lib64/python3.12/site-packages/pikepdf/_methods.py", line 1173, in __getattr__
      def __getattr__(self, name):
      
  SystemError: <built-in method  of PyCapsule object at 0x7fa7d7866430> returned a result with an exception set
  
    warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))

tests/test_pages.py::test_unattached_page
  /usr/lib/python3.12/site-packages/_pytest/unraisableexception.py:78: PytestUnraisableExceptionWarning: Exception ignored in garbage collection: None
  
  ValueError: Page is not attached to a Pdf
  
  The above exception was the direct cause of the following exception:
  
  SystemError: <built-in method  of PyCapsule object at 0x7f640915ff30> returned a result with an exception set
  
  ...
  
  The above exception was the direct cause of the following exception:
  
  Traceback (most recent call last):
    File "/builddir/build/BUILDROOT/python-pikepdf-7.2.0-1.fc39.x86_64/usr/lib64/python3.12/site-packages/pikepdf/_methods.py", line 1173, in __getattr__
      def __getattr__(self, name):
      
  SystemError: <built-in method  of PyCapsule object at 0x7f640915ff30> returned a result with an exception set
  
    warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))

tests/test_pages.py::test_unindexed_page
  /usr/lib/python3.12/site-packages/_pytest/unraisableexception.py:78: PytestUnraisableExceptionWarning: Exception ignored in garbage collection: None
  
  ValueError: Page is not consistently registered with Pdf
  
  The above exception was the direct cause of the following exception:
  
  SystemError: <built-in method  of PyCapsule object at 0x7f640915ff30> returned a result with an exception set
  
...
  
  The above exception was the direct cause of the following exception:
  
  SystemError: <built-in method  of PyCapsule object at 0x7f640915ff30> returned a result with an exception set
  
  The above exception was the direct cause of the following exception:
  
  Traceback (most recent call last):
    File "/builddir/build/BUILDROOT/python-pikepdf-7.2.0-1.fc39.x86_64/usr/lib64/python3.12/site-packages/pikepdf/_methods.py", line 1173, in __getattr__
      def __getattr__(self, name):
      
  SystemError: <built-in method  of PyCapsule object at 0x7f640915ff30> returned a result with an exception set
  
    warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
SKIPPED [1] tests/test_metadata.py:594: test too slow for rasppi arm
SKIPPED [1] tests/test_image_access.py:761: jbig2dec not installed
SKIPPED [1] tests/test_image_access.py:767: jbig2dec not installed
SKIPPED [1] tests/test_image_access.py:776: jbig2dec not installed
SKIPPED [1] tests/test_image_access.py:797: jbig2dec not installed
SKIPPED [1] tests/test_image_access.py:806: jbig2dec not installed
SKIPPED [1] tests/test_pdfa.py:63: verapdf not available
SKIPPED [1] tests/test_pdfa.py:81: verapdf not available
SKIPPED [1] tests/test_private_pdfs.py:30: private resources not available
XFAIL tests/test_foreign.py::test_issue_271 - current qpdf behavior
XPASS tests/test_objectlist.py::test_objectlist_repr Needs further investigation
FAILED tests/test_dictionary.py::test_get_equality_dict - AttributeError: str...
FAILED tests/test_object.py::test_stack_depth - Failed: DID NOT RAISE <class ...
FAILED tests/test_page.py::TestAddResource::test_resources_exists_but_wrong_type
FAILED tests/test_pages.py::test_unattached_page - AttributeError: obj
FAILED tests/test_pages.py::test_unindexed_page - AttributeError: obj
= 5 failed, 542 passed, 9 skipped, 1 xfailed, 1 xpassed, 3 warnings in 10.15s ==


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

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.12/fedora-rawhide-x86_64/05934735-python-pikepdf/

For all our attempts to build python-pikepdf with Python 3.12, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.12/package/python-pikepdf/

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.12:
https://copr.fedorainfracloud.org/coprs/g/python/python3.12/

Let us know here if you have any questions.

Python 3.12 is planned to be included in Fedora 39. To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.12.
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.


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