Bug 1970626

Summary: emoji-picker broken by python-3.10
Product: [Fedora] Fedora Reporter: Kevin Fenzi <kevin>
Component: ibus-typing-boosterAssignee: Mike FABIAN <mfabian>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: anish.developer, i18n-bugs, mfabian, mhroncok
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: ibus-typing-booster-2.11.5-1.fc35 ibus-typing-booster-2.11.5-1.fc34 ibus-typing-booster-2.11.5-1.fc33 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-06-22 07:34:10 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: 1890881    

Description Kevin Fenzi 2021-06-10 20:28:11 UTC
Trying to run emoji-picker with: 

python3-3.10.0~b2-3.fc35.x86_64
ibus-typing-booster-2.11.4-1.fc35.noarch

gives:

✗ emoji-picker 
/usr/lib64/python3.10/enum.py:73: Warning: unsupported arithmetic operation for flags type
  num &= num - 1
Traceback (most recent call last):
  File "/usr/share/ibus-typing-booster/engine/emoji_picker.py", line 42, in <module>
    import itb_util
  File "/usr/share/ibus-typing-booster/engine/itb_util.py", line 3191, in <module>
    class InputHints(Flag):
  File "/usr/lib64/python3.10/enum.py", line 484, in __new__
    raise exc
  File "/usr/lib64/python3.10/enum.py", line 246, in __set_name__
    and _is_single_bit(value)
  File "/usr/lib64/python3.10/enum.py", line 73, in _is_single_bit
    num &= num - 1
TypeError: unsupported operand type(s) for &=: 'InputHints' and 'NoneType'

Comment 1 Kevin Fenzi 2021-06-10 20:32:42 UTC
Miro, should this block some python 3.10 tracker?

Comment 2 Miro Hrončok 2021-06-10 21:55:45 UTC
This is the minimal failing example extracted from /usr/share/ibus-typing-booster/engine/itb_util.py:

from enum import Flag
from gi.repository import Gtk

class InputHints(Flag):
    def __new__(cls, attr: str):
        obj = object.__new__(cls)
        if hasattr(Gtk, 'InputHints') and hasattr(Gtk.InputHints, attr):
            obj._value_ = getattr(Gtk.InputHints, attr)
            print(f'{obj._value_=}')
        else:
            obj._value_ = 0
        return obj

    SPELLCHECK = ('SPELLCHECK')


The output is:

$ python3 reproducer.py 
...
obj._value_=<flags GTK_INPUT_HINT_SPELLCHECK of type Gtk.InputHints>
/usr/lib64/python3.10/enum.py:73: Warning: unsupported arithmetic operation for flags type
  num &= num - 1
Traceback (most recent call last):
  File "//reproducer.py", line 20, in <module>
    class InputHints(Flag):
  File "/usr/lib64/python3.10/enum.py", line 484, in __new__
    raise exc
  File "/usr/lib64/python3.10/enum.py", line 246, in __set_name__
    and _is_single_bit(value)
  File "/usr/lib64/python3.10/enum.py", line 73, in _is_single_bit
    num &= num - 1
TypeError: unsupported operand type(s) for &=: 'InputHints' and 'NoneType'


Setting obj._value_ = 0 does not produce the traceback.

Actually setting obj._value_ to any number does not produce the traceback.


My guess is that with the enum.Flag implementation overhaul, some internals have changed. I don't think messing with obj._value_ in __new__ is a supported thing to do, so I won't consider this a Python bug per se -- obj._value_ is supposed to be a numeric value, not another Flag member.


Replacing:

    obj._value_ = getattr(Gtk.InputHints, attr)

With:

    obj._value_ = int(getattr(Gtk.InputHints, attr))

In both InputHints and InputPurpose seems to get the job done.

Comment 3 Miro Hrončok 2021-06-11 09:47:47 UTC
Upstream PR: https://github.com/mike-fabian/ibus-typing-booster/pull/168

Comment 4 Miro Hrončok 2021-06-21 07:36:21 UTC
Mike, could you please have a look at the proposed Pull Request and backport it to rawhide if possible? Thanks

Comment 5 Mike FABIAN 2021-06-21 13:09:42 UTC
Looking ...

Comment 6 Mike FABIAN 2021-06-21 17:46:09 UTC
python3-enchant seems broken in rawhide:

https://bugzilla.redhat.com/show_bug.cgi?id=1974452

(I noticed this because a test case for Czech failed  when I wanted to fix this bug for ibus-typing-booster in rawhide)

Comment 7 Fedora Update System 2021-06-22 07:32:48 UTC
FEDORA-2021-52fe390975 has been submitted as an update to Fedora 35. https://bodhi.fedoraproject.org/updates/FEDORA-2021-52fe390975

Comment 8 Fedora Update System 2021-06-22 07:34:10 UTC
FEDORA-2021-52fe390975 has been pushed to the Fedora 35 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 9 Fedora Update System 2021-06-22 07:37:36 UTC
FEDORA-2021-48e5f2056e has been submitted as an update to Fedora 34. https://bodhi.fedoraproject.org/updates/FEDORA-2021-48e5f2056e

Comment 10 Fedora Update System 2021-06-22 07:38:29 UTC
FEDORA-2021-468626eba4 has been submitted as an update to Fedora 33. https://bodhi.fedoraproject.org/updates/FEDORA-2021-468626eba4

Comment 12 Fedora Update System 2021-06-23 02:00:44 UTC
FEDORA-2021-48e5f2056e has been pushed to the Fedora 34 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2021-48e5f2056e`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2021-48e5f2056e

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 13 Fedora Update System 2021-06-24 14:42:49 UTC
FEDORA-2021-468626eba4 has been pushed to the Fedora 33 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2021-468626eba4`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2021-468626eba4

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 14 Fedora Update System 2021-07-01 01:13:12 UTC
FEDORA-2021-48e5f2056e has been pushed to the Fedora 34 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 15 Fedora Update System 2021-07-02 01:20:20 UTC
FEDORA-2021-468626eba4 has been pushed to the Fedora 33 stable repository.
If problem still persists, please make note of it in this bug report.