Skip to content

Commit

Permalink
When logging role and states for dev info use names of the enum membe…
Browse files Browse the repository at this point in the history
…rs. (#15708)

Fixes #15703

Summary of the issue:
In Alphas of NVDA compiled with Python 3.11 role and states in the developer info were shown as integer values of the underlying enum members, and not as, more readable, member names. This is due to a change in Python 3.11, which adds a new base class for IntEnum and IntFlag which converts the members to string in the same way their underlying type (in this particular case integers) are formatted. Since we convert both role and states implicitly (using %s) to string in the developer info the member description is replaced with the meaningless integer value there.

Description of user facing changes
Role and states are once again displayed as names in the developer info.

Description of development approach
When logging these properties we are logging their names directly, rather than converting enum members to string.
  • Loading branch information
lukaszgo1 committed Oct 31, 2023
1 parent 3ac42fe commit d6ed3f5
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions source/NVDAObjects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1427,16 +1427,15 @@ def _get_devInfo(self) -> typing.List[str]: # noqa: C901
except Exception as e:
ret = "exception: %s" % e
info.append("name: %s" % ret)
ret = self.role
info.append("role: %s" % ret)
info.append(f"role: {self.role.name}")
info.append(f"processID: {self.processID}")
try:
ret = repr(self.roleText)
except Exception as e:
ret = f"exception: {e}"
info.append(f"roleText: {ret}")
try:
ret = ", ".join(str(state) for state in self.states)
ret = ", ".join(state.name for state in self.states)
except Exception as e:
ret = "exception: %s" % e
info.append("states: %s" % ret)
Expand Down

0 comments on commit d6ed3f5

Please sign in to comment.