Bug 2283518

Summary: python-rdflib fails to build with Python 3.13: AttributeError: '_pickle.Pickler' object attribute 'persistent_id' is read-only
Product: [Fedora] Fedora Reporter: Karolina Surma <ksurma>
Component: python-rdflibAssignee: Nils Philippsen <nphilipp>
Status: CLOSED WORKSFORME QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: djc, eclipseo, fti-bugs, ksurma, mhroncok, michel, mtasaka, negativo17, nphilipp, pingou
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-06-16 08:13:47 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2218117, 2260875, 2244836, 2260877, 2291678, 2291804, 2291828, 2291850, 2291921, 2292024, 2292523    

Description Karolina Surma 2024-05-27 15:26:29 UTC
python-rdflib fails to build with Python 3.13.0b1.


__________________ TestUtil.test_to_bits_from_bits_round_trip __________________

self = <test_nodepickler.TestUtil object at 0x7f5277295810>

        def test_to_bits_from_bits_round_trip(self):
            np = NodePickler()
    
            a = Literal(
                """A test with a \\n (backslash n), "\u00a9" , and newline \n and a second line.
    """
            )
>           b = np.loads(np.dumps(a))

test/test_store/test_nodepickler.py:32: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <rdflib.store.NodePickler object at 0x7f52751b1fd0>
obj = rdflib.term.Literal('A test with a \\n (backslash n), "©" , and newline \n and a second line.\n')
protocol = None, bin = None

    def dumps(
        self, obj: "Node", protocol: Optional[Any] = None, bin: Optional[Any] = None
    ):
        src = BytesIO()
        p = Pickler(src)
        # NOTE on type error: https://github.com/python/mypy/issues/2427
        # type error: Cannot assign to a method
>       p.persistent_id = self._get_ids  # type: ignore[assignment]
E       AttributeError: '_pickle.Pickler' object attribute 'persistent_id' is read-only

rdflib/store.py:149: AttributeError
_________________________ TestUtil.test_literal_cases __________________________

self = <test_nodepickler.TestUtil object at 0x7f5277295950>

    def test_literal_cases(self):
        np = NodePickler()
    
        for l in cases:
            a = Literal(l)
>           b = np.loads(np.dumps(a))

test/test_store/test_nodepickler.py:40: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <rdflib.store.NodePickler object at 0x7f5273890a50>
obj = rdflib.term.Literal('no quotes'), protocol = None, bin = None

    def dumps(
        self, obj: "Node", protocol: Optional[Any] = None, bin: Optional[Any] = None
    ):
        src = BytesIO()
        p = Pickler(src)
        # NOTE on type error: https://github.com/python/mypy/issues/2427
        # type error: Cannot assign to a method
>       p.persistent_id = self._get_ids  # type: ignore[assignment]
E       AttributeError: '_pickle.Pickler' object attribute 'persistent_id' is read-only

FAILED test/test_store/test_nodepickler.py::TestUtil::test_to_bits_from_bits_round_trip
FAILED test/test_store/test_nodepickler.py::TestUtil::test_literal_cases - At...

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

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.13/fedora-rawhide-x86_64/07495797-python-rdflib/

For all our attempts to build python-rdflib with Python 3.13, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.13/package/python-rdflib/

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

Let us know here if you have any questions.

Python 3.13 is planned to be included in Fedora 41.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.13.
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 Karolina Surma 2024-06-12 15:06:55 UTC
*** Bug 2291894 has been marked as a duplicate of this bug. ***

Comment 2 Michel Lind 2024-06-13 08:36:18 UTC
I have a hacky patch that gets this to build, but

a) I can't figure out what announced change in Python 3.13 causes this behavior (pickle.{Pickler,Unpickler} methods not being overrideable without subclassing)
b) this leaks new class definitions (which I indicate are not meant to be public by underscores, but still) so probably should not be merged as is, but should be reported upstream by one of the package maintainers

https://src.fedoraproject.org/rpms/python-rdflib/pull-request/5

Comment 4 Dominik 'Rathann' Mierzejewski 2024-06-14 09:51:28 UTC
FYI this is causing ffmpeg to FTBFS (via lv2-devel).

Comment 5 Fedora Fails To Install 2024-06-16 08:13:47 UTC
Hello,

Please note that this comment was generated automatically by https://pagure.io/releng/blob/main/f/scripts/ftbfs-fti/follow-policy.py
If you feel that this output has mistakes, please open an issue at https://pagure.io/releng/

All subpackages of a package against which this bug was filled are now installable or removed from Fedora 41.

Thanks for taking care of it!