Page MenuHomePhabricator

"TypeError: 'dict_keys' object does not support indexing" in cosmetic_changes.py (Python 3)
Closed, ResolvedPublic

Description

Traceback (most recent call last):
  File "xyz\xxx\yyy.py", line 89, in <module>
    page.put(page_text, summary)
  File "xyz\pywikibot-core\pywikibot\tools\__init__.py", line 1105, in wrapper
    return obj(*__args, **__kw)
  File "xyz\pywikibot-core\pywikibot\page.py", line 1144, in put
    **kwargs)
  File "xyz\pywikibot-core\pywikibot\tools\__init__.py", line 1105, in wrapper
    return obj(*__args, **__kw)
  File "xyz\pywikibot-core\pywikibot\page.py", line 1062, in save
    cc=apply_cosmetic_changes, **kwargs)
  File "xyz\pywikibot-core\pywikibot\page.py", line 1070, in _save
    summary = self._cosmetic_changes_hook(summary) or summary
  File "xyz\pywikibot-core\pywikibot\page.py", line 1120, in _cosmetic_changes_hook
    self.text = ccToolkit.change(old)
  File "xyz\pywikibot-core\pywikibot\cosmetic_changes.py", line 279, in change
    new_text = self._change(text)
  File "xyz\pywikibot-core\pywikibot\cosmetic_changes.py", line 273, in _change
    text = self.safe_execute(method, text)
  File "xyz\pywikibot-core\pywikibot\cosmetic_changes.py", line 260, in safe_execute
    result = method(text)
  File "xyz\pywikibot-core\pywikibot\cosmetic_changes.py", line 849, in fixArabicLetters
    old = digits[digits.keys()[0]]
TypeError: 'dict_keys' object does not support indexing

In Python 3 the dict.keys() method returns a dictionary view object, which does not support indexing.

Details

Related Gerrit Patches:

Event Timeline

Dalba created this task.Jun 9 2015, 2:30 AM
Dalba raised the priority of this task from to Needs Triage.
Dalba updated the task description. (Show Details)
Dalba added a project: Pywikibot.
Dalba added a subscriber: Dalba.
Restricted Application added subscribers: Aklapper, Unknown Object (MLST). · View Herald TranscriptJun 9 2015, 2:30 AM
jayvdb triaged this task as High priority.Jun 9 2015, 5:28 AM
Dalba updated the task description. (Show Details)Jun 9 2015, 5:40 AM
Dalba set Security to None.
XZise added a subscriber: XZise.Jun 9 2015, 8:06 AM

digits[digits.keys()[0]] might become list(digits.values())[0], but that part looks broken anyway...

XZise added a comment.Jun 9 2015, 1:09 PM

It seems that this code isn't actually used further down.

The second half of this method was de-activated due to T57185.

Change 246793 had a related patch set uploaded (by John Vandenberg):
Fix Python 3 TypeError in fixArabicLetters

https://gerrit.wikimedia.org/r/246793

Restricted Application added a subscriber: TerraCodes. · View Herald TranscriptNov 3 2017, 9:18 AM
matej_suchanek closed this task as Resolved.Nov 3 2017, 7:43 PM
matej_suchanek assigned this task to Ladsgroup.
matej_suchanek removed a project: Patch-For-Review.
Restricted Application added a project: User-Ladsgroup. · View Herald TranscriptNov 3 2017, 7:44 PM