Skip to content

TestUtil.test_to_bits_from_bits_round_trip test failure with python3.13b2 #2801

Open
@mtasaka

Description

@mtasaka

Fedora project is now planning to import python 3.13 into Fedora 40, and now trying to rebuild all packages in Fedora with python 3.13b2 .

With rdflib 7.0.0, testsuite TestUtil.test_to_bits_from_bits_round_trip fails with python 3.13b2 as:

__________________ TestUtil.test_to_bits_from_bits_round_trip __________________
self = <test_nodepickler.TestUtil object at 0x7fe577cee490>
        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 0x7fe5742e5010>
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 0x7fe577cee5d0>
    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 0x7fe5742cd450>
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
rdflib/store.py:149: AttributeError

Looks like this assignment is no longer accepted.

up.persistent_load = self._get_object # type: ignore[assignment]

p.persistent_id = self._get_ids # type: ignore[assignment]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions