Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 1796400 - python-uranium fails to build with Python 3.9: encoding parameter of json.loads() has been removed
Summary: python-uranium fails to build with Python 3.9: encoding parameter of json.loa...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: python-uranium
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Miro Hrončok
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON39
TreeView+ depends on / blocked
 
Reported: 2020-01-30 10:44 UTC by Miro Hrončok
Modified: 2020-04-22 17:55 UTC (History)
4 users (show)

Fixed In Version: python-uranium-4.6.0-1.fc33
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-04-22 17:55:52 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github Ultimaker Uranium pull 574 0 None closed Remove deprecated/ignored encoding parameter of json.loads() 2020-04-22 17:53:57 UTC

Description Miro Hrončok 2020-01-30 10:44:53 UTC
python-uranium fails to build with Python 3.9.0a3.

_________________________ test_installAndRemovePackage _________________________
    def test_installAndRemovePackage():
        mock_application = MagicMock()
        mock_registry = MagicMock()
        mock_registry.isActivePlugin = MagicMock(return_value = False)
        mock_application.getPluginRegistry = MagicMock(return_value = mock_registry)
        manager = PackageManager(mock_application)
        manager.installedPackagesChanged = MagicMock()
        manager.installPackage(test_package_path)
        assert manager.installedPackagesChanged.emit.call_count == 1
        assert manager.isPackageInstalled("UnitTestPackage")
    
        info = manager.getInstalledPackageInfo("UnitTestPackage")
        assert info["author"]["author_id"] == "nallath"
        assert info["display_name"] == "UnitTestPackage"
    
        # We don't want the package to be purged. We need that package for the other tests!
        with patch("os.remove", MagicMock()):
            manager._installPackage({"package_info": info, "filename": test_package_path})
    
        assert "UnitTestPackage" in manager.getAllInstalledPackageIDs()
        assert manager.isUserInstalledPackage("UnitTestPackage")
        assert manager.getAllInstalledPackagesInfo()["plugin"][0]["display_name"] == "UnitTestPackage"
>       manager.initialize()
tests/TestPackageManager.py:90: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
UM/PackageManager.py:77: in initialize
    self._loadManagementData()
UM/PackageManager.py:138: in _loadManagementData
    self._bundled_package_dict.update(json.load(f, encoding = "utf-8"))
/usr/lib64/python3.9/json/__init__.py:293: in load
    return loads(fp.read(),
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
s = '{\n    "ConsoleLogger": {\n        "package_info": {\n            "package_id": "ConsoleLogger",\n            "packag...ail": "plugins",\n                "website": "https://ultimaker.com"\n            }\n        }\n    }\n}'
cls = <class 'json.decoder.JSONDecoder'>, object_hook = None, parse_float = None
parse_int = None, parse_constant = None, object_pairs_hook = None
kw = {'encoding': 'utf-8'}
    def loads(s, *, cls=None, object_hook=None, parse_float=None,
            parse_int=None, parse_constant=None, object_pairs_hook=None, **kw):
        """Deserialize ``s`` (a ``str``, ``bytes`` or ``bytearray`` instance
        containing a JSON document) to a Python object.
    
        ``object_hook`` is an optional function that will be called with the
        result of any object literal decode (a ``dict``). The return value of
        ``object_hook`` will be used instead of the ``dict``. This feature
        can be used to implement custom decoders (e.g. JSON-RPC class hinting).
    
        ``object_pairs_hook`` is an optional function that will be called with the
        result of any object literal decoded with an ordered list of pairs.  The
        return value of ``object_pairs_hook`` will be used instead of the ``dict``.
        This feature can be used to implement custom decoders.  If ``object_hook``
        is also defined, the ``object_pairs_hook`` takes priority.
    
        ``parse_float``, if specified, will be called with the string
        of every JSON float to be decoded. By default this is equivalent to
        float(num_str). This can be used to use another datatype or parser
        for JSON floats (e.g. decimal.Decimal).
    
        ``parse_int``, if specified, will be called with the string
        of every JSON int to be decoded. By default this is equivalent to
        int(num_str). This can be used to use another datatype or parser
        for JSON integers (e.g. float).
    
        ``parse_constant``, if specified, will be called with one of the
        following strings: -Infinity, Infinity, NaN.
        This can be used to raise an exception if invalid JSON numbers
        are encountered.
    
        To use a custom ``JSONDecoder`` subclass, specify it with the ``cls``
        kwarg; otherwise ``JSONDecoder`` is used.
        """
        if isinstance(s, str):
            if s.startswith('\ufeff'):
                raise JSONDecodeError("Unexpected UTF-8 BOM (decode using utf-8-sig)",
                                      s, 0)
        else:
            if not isinstance(s, (bytes, bytearray)):
                raise TypeError(f'the JSON object must be str, bytes or bytearray, '
                                f'not {s.__class__.__name__}')
            s = s.decode(detect_encoding(s), 'surrogatepass')
    
        if (cls is None and object_hook is None and
                parse_int is None and parse_float is None and
                parse_constant is None and object_pairs_hook is None and not kw):
            return _default_decoder.decode(s)
        if cls is None:
            cls = JSONDecoder
        if object_hook is not None:
            kw['object_hook'] = object_hook
        if object_pairs_hook is not None:
            kw['object_pairs_hook'] = object_pairs_hook
        if parse_float is not None:
            kw['parse_float'] = parse_float
        if parse_int is not None:
            kw['parse_int'] = parse_int
        if parse_constant is not None:
            kw['parse_constant'] = parse_constant
>       return cls(**kw).decode(s)
E       TypeError: __init__() got an unexpected keyword argument 'encoding'
/usr/lib64/python3.9/json/__init__.py:359: TypeError
----------------------------- Captured stdout call -----------------------------
[MainThread] UM.PackageManager.__init__ [52]: Found bundled packages JSON file: /builddir/build/BUILD/Uranium-4.4.0/UM/../resources/bundled_packages/uranium.json
[MainThread] UM.PackageManager.getPackageInfo [515]: Found potential package.json file '/package.json'
[MainThread] UM.PackageManager.installPackage [373]: Package [UnitTestPackage] version [1.0.0] is scheduled to be installed.
[MainThread] UM.PackageManager._saveManagementData [224]: Package management file /builddir/.local/share/test/1.0/packages.json was saved
[MainThread] UM.PackageManager._installPackage [454]: Installing package [UnitTestPackage] from file [/builddir/build/BUILD/Uranium-4.4.0/tests/UnitTestPackage.package]
[MainThread] UM.PackageManager.__installPackageFiles [501]: Moving package UnitTestPackage from /tmp/tmpdhw8iziv/files/plugins to /builddir/.local/share/test/1.0/plugins/UnitTestPackage

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.9/fedora-rawhide-x86_64/01200010-python-uranium/

For all our attempts to build python-uranium with Python 3.9, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.9/package/python-uranium/

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

Let us know here if you have any questions.

Python 3.9 will be included in Fedora 33. To make that update smoother, we're building Fedora packages with early pre-releases of Python 3.9.
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 Miro Hrončok 2020-01-30 10:49:29 UTC
Upstream pull request: https://github.com/Ultimaker/Uranium/pull/574

Comment 2 Ben Cotton 2020-02-11 17:22:34 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 32 development cycle.
Changing version to 32.


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