Bug 2336889 - pybind11 fails to build with Python 3.14: AttributeError: 'pybind11_tests.pickling.PickleableWithDict' object has no attribute 'dynamic' + AssertionError
Summary: pybind11 fails to build with Python 3.14: AttributeError: 'pybind11_tests.pic...
Keywords:
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: pybind11
Version: 42
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
Assignee: Susi Lehtola
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.14
TreeView+ depends on / blocked
 
Reported: 2025-01-10 09:36 UTC by Karolina Surma
Modified: 2025-02-26 13:22 UTC (History)
6 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed:
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github pybind pybind11 issues 5499 0 None open [BUG]: Python 3.14.0a3 test failure: test_roundtrip_with_dict: AttributeError: 'pybind11_tests.pickling.PickleableWithDi... 2025-01-23 09:49:28 UTC

Description Karolina Surma 2025-01-10 09:36:31 UTC
pybind11 fails to build with Python 3.14.0a3.

___________________________ test_dynamic_attributes ____________________________

    @pytest.mark.xfail("env.PYPY")
    def test_dynamic_attributes():
        instance = m.DynamicClass()
        assert not hasattr(instance, "foo")
        assert "foo" not in dir(instance)
    
        # Dynamically add attribute
        instance.foo = 42
        assert hasattr(instance, "foo")
        assert instance.foo == 42
        assert "foo" in dir(instance)
    
        # __dict__ should be accessible and replaceable
        assert "foo" in instance.__dict__
        instance.__dict__ = {"bar": True}
>       assert not hasattr(instance, "foo")
E       AssertionError: assert not True
E        +  where True = hasattr(<pybind11_tests.methods_and_attributes.DynamicClass object at 0x7f7c18238330>, 'foo')

instance   = <pybind11_tests.methods_and_attributes.DynamicClass object at 0x7f7c18238330>

../../tests/test_methods_and_attributes.py:312: AssertionError
----------------------------- Captured stdout call -----------------------------
### test_submodule_methods_and_attributes(module_&)::DynamicClass @ 0x5588e466d1b0 created via default constructor
_________________ test_roundtrip_with_dict[PickleableWithDict] _________________

cls_name = 'PickleableWithDict'

    @pytest.mark.xfail("env.PYPY")
    @pytest.mark.parametrize("cls_name", ["PickleableWithDict", "PickleableWithDictNew"])
    def test_roundtrip_with_dict(cls_name):
        cls = getattr(m, cls_name)
        p = cls("test_value")
        p.extra = 15
        p.dynamic = "Attribute"
    
        data = pickle.dumps(p, pickle.HIGHEST_PROTOCOL)
        p2 = pickle.loads(data)
        assert p2.value == p.value
        assert p2.extra == p.extra
>       assert p2.dynamic == p.dynamic
E       AttributeError: 'pybind11_tests.pickling.PickleableWithDict' object has no attribute 'dynamic'

cls        = <class 'pybind11_tests.pickling.PickleableWithDict'>
cls_name   = 'PickleableWithDict'
data       = b'\x80\x05\x95`\x00\x00\x00\x00\x00\x00\x00\x8c\x17pybind11_tests.pickling\x94\x8c\x12PickleableWithDict\x94\x93\x94)\x81\x94\x8c\ntest_value\x94K\x0f}\x94\x8c\x07dynamic\x94\x8c\tAttribute\x94s\x87\x94b.'
p          = <pybind11_tests.pickling.PickleableWithDict object at 0x7f7c182395e0>
p2         = <pybind11_tests.pickling.PickleableWithDict object at 0x7f7c18239470>

../../tests/test_pickling.py:52: AttributeError
_______________ test_roundtrip_with_dict[PickleableWithDictNew] ________________

cls_name = 'PickleableWithDictNew'

    @pytest.mark.xfail("env.PYPY")
    @pytest.mark.parametrize("cls_name", ["PickleableWithDict", "PickleableWithDictNew"])
    def test_roundtrip_with_dict(cls_name):
        cls = getattr(m, cls_name)
        p = cls("test_value")
        p.extra = 15
        p.dynamic = "Attribute"
    
        data = pickle.dumps(p, pickle.HIGHEST_PROTOCOL)
        p2 = pickle.loads(data)
        assert p2.value == p.value
        assert p2.extra == p.extra
>       assert p2.dynamic == p.dynamic
E       AttributeError: 'pybind11_tests.pickling.PickleableWithDictNew' object has no attribute 'dynamic'

cls        = <class 'pybind11_tests.pickling.PickleableWithDictNew'>
cls_name   = 'PickleableWithDictNew'
data       = b'\x80\x05\x95c\x00\x00\x00\x00\x00\x00\x00\x8c\x17pybind11_tests.pickling\x94\x8c\x15PickleableWithDictNew\x94\x93\x94)\x81\x94\x8c\ntest_value\x94K\x0f}\x94\x8c\x07dynamic\x94\x8c\tAttribute\x94s\x87\x94b.'
p          = <pybind11_tests.pickling.PickleableWithDictNew object at 0x7f7c18239750>
p2         = <pybind11_tests.pickling.PickleableWithDictNew object at 0x7f7c182398c0>

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

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.14/fedora-rawhide-x86_64/08480163-pybind11/

For all our attempts to build pybind11 with Python 3.14, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.14/package/pybind11/

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

Let us know here if you have any questions.

Python 3.14 is planned to be included in Fedora 43.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.14.
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 Aoife Moloney 2025-02-26 13:22:02 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 42 development cycle.
Changing version to 42.


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