Skip to content

Commit

Permalink
NVDAObjects/Python 3: dict.iteritems -> dict.items. Re nvaccess#9067.
Browse files Browse the repository at this point in the history
  • Loading branch information
josephsl committed Jun 4, 2019
1 parent 84bac63 commit 1e017cd
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
10 changes: 5 additions & 5 deletions source/NVDAObjects/IAccessible/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1378,7 +1378,7 @@ def _get_positionInfo(self):
d=self.decodedAccDescription
if d and not isinstance(d,basestring):
groupdict=d.groupdict()
return {x:int(y) for x,y in groupdict.iteritems() if y is not None}
return {x:int(y) for x,y in groupdict.items() if y is not None}
if self.allowIAccessibleChildIDAndChildCountForPositionInfo and self.IAccessibleChildID>0:
indexInGroup=self.IAccessibleChildID
parent=self.parent
Expand Down Expand Up @@ -1505,7 +1505,7 @@ def _get_devInfo(self):
info.append("IAccessible accName: %s" % ret)
try:
ret = iaObj.accRole(childID)
for name, const in oleacc.__dict__.iteritems():
for name, const in oleacc.__dict__.items():
if not name.startswith("ROLE_"):
continue
if ret == const:
Expand All @@ -1519,7 +1519,7 @@ def _get_devInfo(self):
try:
temp = iaObj.accState(childID)
ret = ", ".join(
name for name, const in oleacc.__dict__.iteritems()
name for name, const in oleacc.__dict__.items()
if name.startswith("STATE_") and temp & const
) + " (%d)" % temp
except Exception as e:
Expand Down Expand Up @@ -1548,7 +1548,7 @@ def _get_devInfo(self):
info.append("IAccessible2 uniqueID: %s" % ret)
try:
ret = iaObj.role()
for name, const in itertools.chain(oleacc.__dict__.iteritems(), IAccessibleHandler.__dict__.iteritems()):
for name, const in itertools.chain(oleacc.__dict__.items(), IAccessibleHandler.__dict__.items()):
if not name.startswith("ROLE_") and not name.startswith("IA2_ROLE_"):
continue
if ret == const:
Expand All @@ -1562,7 +1562,7 @@ def _get_devInfo(self):
try:
temp = iaObj.states
ret = ", ".join(
name for name, const in IAccessibleHandler.__dict__.iteritems()
name for name, const in IAccessibleHandler.__dict__.items()
if name.startswith("IA2_STATE_") and temp & const
) + " (%d)" % temp
except Exception as e:
Expand Down
4 changes: 2 additions & 2 deletions source/NVDAObjects/UIA/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,11 +1039,11 @@ def _get_devInfo(self):
info.append("UIA className: %s"%ret)
patternsAvailable = []
patternAvailableConsts = dict(
(const, name) for name, const in UIAHandler.__dict__.iteritems()
(const, name) for name, const in UIAHandler.__dict__.items()
if name.startswith("UIA_Is") and name.endswith("PatternAvailablePropertyId")
)
self._prefetchUIACacheForPropertyIDs(list(patternAvailableConsts))
for const, name in patternAvailableConsts.iteritems():
for const, name in patternAvailableConsts.items():
try:
res = self._getUIACacheablePropertyValue(const)
except COMError:
Expand Down
4 changes: 2 additions & 2 deletions source/NVDAObjects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1144,15 +1144,15 @@ def _get_devInfo(self):
info.append("name: %s" % ret)
try:
ret = self.role
for name, const in controlTypes.__dict__.iteritems():
for name, const in controlTypes.__dict__.items():
if name.startswith("ROLE_") and ret == const:
ret = name
break
except Exception as e:
ret = "exception: %s" % e
info.append("role: %s" % ret)
try:
stateConsts = dict((const, name) for name, const in controlTypes.__dict__.iteritems() if name.startswith("STATE_"))
stateConsts = dict((const, name) for name, const in controlTypes.__dict__.items() if name.startswith("STATE_"))
ret = ", ".join(
stateConsts.get(state) or str(state)
for state in self.states)
Expand Down
2 changes: 1 addition & 1 deletion source/NVDAObjects/window/excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,7 @@ def _get_states(self):
if not cellInfo:
return states
stateBits=cellInfo.states
for k,v in vars(controlTypes).iteritems():
for k,v in vars(controlTypes).items():
if k.startswith('STATE_') and stateBits&v:
states.add(v)
return states
Expand Down
3 changes: 2 additions & 1 deletion source/NVDAObjects/window/winword.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,8 @@ def getTextWithFields(self,formatConfig=None):
startOffset=self._rangeObj.start
endOffset=self._rangeObj.end
text=BSTR()
formatConfigFlags=sum(y for x,y in formatConfigFlagsMap.iteritems() if formatConfig.get(x,False))
# #9067: format config flags map is a dictionary.
formatConfigFlags=sum(y for x,y in formatConfigFlagsMap.items() if formatConfig.get(x,False))
if self.shouldIncludeLayoutTables:
formatConfigFlags+=formatConfigFlag_includeLayoutTables
if self.obj.ignoreEditorRevisions:
Expand Down

0 comments on commit 1e017cd

Please sign in to comment.