Bug 1833579

Summary: python-fedora contains Python 3.9 incompatible code: encoding parameter of json.loads() has been removed
Product: [Fedora] Fedora Reporter: Miro Hrončok <mhroncok>
Component: python-fedoraAssignee: Fedora Infrastructure SIG <infra-sig>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: rawhideCC: infra-sig, jonstanley, randy
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: 2020-05-19 15:52:14 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: 1785415, 1814243    

Description Miro Hrončok 2020-05-08 23:13:36 UTC
See https://bugzilla.redhat.com/show_bug.cgi?id=1814243#c4 for context.

python-fedora-0.10.0-13 contains Python 3.9 incompatible code:

>       c = bindings.BodhiClient()
bodhi/tests/client/test___init__.py:849: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
bodhi/client/bindings.py:206: in __init__
    super(BodhiClient, self).__init__(base_url, login_url=base_url + 'login', username=username,
/usr/lib/python3.9/site-packages/fedora/client/openidbaseclient.py:181: in __init__
    self._load_cookies()
/usr/lib/python3.9/site-packages/fedora/client/openidbaseclient.py:317: in _load_cookies
    data = json.loads(f.read(), encoding='utf-8')
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
s = '{}', 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


See https://docs.python.org/3.9/whatsnew/3.9.html#removed

"The encoding parameter of json.loads() has been removed. As of Python 3.1, it was deprecated and ignored; using it has emitted a DeprecationWarning since Python 3.8."


The python-fedora builds just fine, because it has no %check, but bodhi fails to build because of this (together with at least 2 more other things).



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.


-----

Setting the severity to high.

This package is part of the initial bootstrap sequence. Without it, we cannot proceed with the bootstrap in a Koji side tag.

https://fedoraproject.org/wiki/Changes/Python3.9#Important_dates_and_plan

The current plan is to follow the "ideal point when we can start rebuilding in Koji" -- that is we need to get this bug fixed approximately in 2 weeks.

That includes potential uncovered bugs in packages that depend on this one.

Please acknowledge that you have read this message and that you can dedicate time to fix it. If you know already that you won't be able to fix it by the deadline, please let us know ASAP, so we can allocate resources to do that. Thank You.

Side note: Sorry for reporting this too late, the missing %check and the fact that bz1814243 is "hiding" this problem in bodhi made us not aware of it.