Bug 2290720 - python-jsonpickle fails to build with Python 3.13: NameError: name 'datetime' is not defined. Did you forget to import 'datetime'?
Summary: python-jsonpickle fails to build with Python 3.13: NameError: name 'datetime'...
Keywords:
Status: CLOSED DUPLICATE of bug 2284005
Alias: None
Product: Fedora
Classification: Fedora
Component: python-jsonpickle
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Gwyn Ciesla
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.13
TreeView+ depends on / blocked
 
Reported: 2024-06-06 13:40 UTC by Karolina Surma
Modified: 2024-06-06 18:30 UTC (History)
5 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2024-06-06 18:30:58 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Karolina Surma 2024-06-06 13:40:59 UTC
python-jsonpickle fails to build with Python 3.13.0b1.

This is probably fixed upstream: https://github.com/jsonpickle/jsonpickle/commit/315b54bcac2c34a93c1863dadedb0dc8c5175bf2

=================================== FAILURES ===================================
___________________ [doctest] jsonpickle.unpickler.loadrepr ____________________
275 Returns an instance of the object from the object's repr() string.
276 It involves the dynamic specification of code.
277 
278 >>> obj = loadrepr('datetime/datetime.datetime.now()')
UNEXPECTED EXCEPTION: NameError("name 'datetime' is not defined")
Traceback (most recent call last):
  File "/usr/lib64/python3.13/doctest.py", line 1395, in __run
    exec(compile(example.source, filename, "single",
    ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                 compileflags, True), test.globs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<doctest jsonpickle.unpickler.loadrepr[0]>", line 1, in <module>
  File "/builddir/build/BUILD/python-jsonpickle-3.0.4-build/jsonpickle-3.0.4/jsonpickle/unpickler.py", line 289, in loadrepr
    return eval(evalstr)
  File "<string>", line 1, in <module>
NameError: name 'datetime' is not defined. Did you forget to import 'datetime'?
/builddir/build/BUILD/python-jsonpickle-3.0.4-build/jsonpickle-3.0.4/jsonpickle/unpickler.py:278: UnexpectedException
___________________ PicklingTestCase.test_thing_with_module ____________________

self = <jsonpickle_test.PicklingTestCase testMethod=test_thing_with_module>

    def test_thing_with_module(self):
        obj = Thing('with-module')
        obj.themodule = os
    
        flattened = self.pickler.flatten(obj)
>       inflated = self.unpickler.restore(flattened)

tests/jsonpickle_test.py:392: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
jsonpickle/unpickler.py:378: in restore
    value = self._restore(obj)
jsonpickle/unpickler.py:360: in _restore
    return restore(obj)
jsonpickle/unpickler.py:797: in _restore_object
    return self._restore_object_instance(obj, cls, class_name)
jsonpickle/unpickler.py:772: in _restore_object_instance
    instance = self._restore_object_instance_variables(obj, instance)
jsonpickle/unpickler.py:706: in _restore_object_instance_variables
    instance = self._restore_from_dict(obj, instance)
jsonpickle/unpickler.py:621: in _restore_from_dict
    value = self._restore(v)
jsonpickle/unpickler.py:360: in _restore
    return restore(obj)
jsonpickle/unpickler.py:548: in _restore_repr
    obj = loadrepr(obj[tags.REPR])
jsonpickle/unpickler.py:289: in loadrepr
    return eval(evalstr)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   ???
E   NameError: name 'os' is not defined. Did you forget to import 'os'?

<string>:1: NameError
__________________ PicklingTestCase.test_thing_with_submodule __________________

self = <jsonpickle_test.PicklingTestCase testMethod=test_thing_with_submodule>

    def test_thing_with_submodule(self):
        obj = Thing('with-submodule')
        obj.submodule = collections
    
        flattened = self.pickler.flatten(obj)
>       inflated = self.unpickler.restore(flattened)

tests/jsonpickle_test.py:408: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
jsonpickle/unpickler.py:378: in restore
    value = self._restore(obj)
jsonpickle/unpickler.py:360: in _restore
    return restore(obj)
jsonpickle/unpickler.py:797: in _restore_object
    return self._restore_object_instance(obj, cls, class_name)
jsonpickle/unpickler.py:772: in _restore_object_instance
    instance = self._restore_object_instance_variables(obj, instance)
jsonpickle/unpickler.py:706: in _restore_object_instance_variables
    instance = self._restore_from_dict(obj, instance)
jsonpickle/unpickler.py:621: in _restore_from_dict
    value = self._restore(v)
jsonpickle/unpickler.py:360: in _restore
    return restore(obj)
jsonpickle/unpickler.py:548: in _restore_repr
    obj = loadrepr(obj[tags.REPR])
jsonpickle/unpickler.py:289: in loadrepr
    return eval(evalstr)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   ???
E   NameError: name 'collections' is not defined. Did you forget to import 'collections'?

<string>:1: NameError

=========================== short test summary info ============================
FAILED jsonpickle/unpickler.py::jsonpickle.unpickler.loadrepr
FAILED tests/jsonpickle_test.py::PicklingTestCase::test_thing_with_module - N...
FAILED tests/jsonpickle_test.py::PicklingTestCase::test_thing_with_submodule
============ 3 failed, 344 passed, 3 xpassed, 25 warnings in 1.29s =============

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/07509658-python-jsonpickle/

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

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 Ben Boeckel 2024-06-06 18:30:58 UTC
FTBFS for this was already resolved. Marking as a duplicate. See this update: https://bodhi.fedoraproject.org/updates/FEDORA-2024-df9351f772

*** This bug has been marked as a duplicate of bug 2284005 ***


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