diff --git a/qutebrowser/utils/debug.py b/qutebrowser/utils/debug.py index 89ae62faf..a516c43f3 100644 --- a/qutebrowser/utils/debug.py +++ b/qutebrowser/utils/debug.py @@ -156,6 +156,10 @@ def qflags_key(base, value, add_base=False, klass=None): klass = value.__class__ if klass == int: raise TypeError("Can't guess enum class of an int!") + + if not value: + return qenum_key(base, value, add_base, klass) + bits = [] names = [] mask = 0x01 diff --git a/tests/unit/utils/test_debug.py b/tests/unit/utils/test_debug.py index 04a2fa436..7bcad59ec 100644 --- a/tests/unit/utils/test_debug.py +++ b/tests/unit/utils/test_debug.py @@ -138,6 +138,7 @@ class TestQEnumKey: (QFrame, QFrame.Sunken, None, 'Sunken'), (QFrame, 0x0030, QFrame.Shadow, 'Sunken'), (QFrame, 0x1337, QFrame.Shadow, '0x1337'), + (Qt, Qt.AnchorLeft, None, 'AnchorLeft'), ]) def test_qenum_key(self, base, value, klass, expected): key = debug.qenum_key(base, value, klass=klass) @@ -168,6 +169,8 @@ class TestQFlagsKey: (Qt, Qt.AlignCenter, None, 'AlignHCenter|AlignVCenter'), fixme((Qt, 0x0021, Qt.Alignment, 'AlignLeft|AlignTop')), (Qt, 0x1100, Qt.Alignment, '0x0100|0x1000'), + (Qt, Qt.DockWidgetAreas(0), Qt.DockWidgetArea, 'NoDockWidgetArea'), + (Qt, Qt.DockWidgetAreas(0), None, '0x0000'), ]) def test_qflags_key(self, base, value, klass, expected): flags = debug.qflags_key(base, value, klass=klass)