earwig / mwparserfromhell

A Python parser for MediaWiki wikicode
https://mwparserfromhell.readthedocs.io/
MIT License
757 stars 75 forks source link

intelliJ IDEA crashes when trying to preview a smart list #220

Closed nyurik closed 4 years ago

nyurik commented 5 years ago

When stepping through my wiktionary parsing code, I often try to look at the Wikicode's nodes element, and almost always IDE shows an error instead of allowing me to view that data.

Example - set breakpoint in the Parser.py 's run() method right after code = mw_parse(...), and examine the code variable. Easiest way to start is run the code with --parse юбка-карандаш parameter (make sure to use python 3.7+).

Error evaluating: thread_id: pid_20335_id_140587393537416
frame_id: 26653320
scope: FRAME
attrs: code _nodes
Traceback (most recent call last):
  File "/home/yurik/.IntelliJIdea2019.2/config/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_vars.py", line 285, in resolve_compound_variable_fields
    return _typeName, resolver.get_dictionary(VariableWithOffset(var, offset) if offset else var)
  File "/home/yurik/.IntelliJIdea2019.2/config/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_resolver.py", line 291, in get_dictionary
    for item in var[offset:offset+MAX_ITEMS_TO_HANDLE]:
  File "/home/yurik/.local/lib/python3.7/site-packages/mwparserfromhell/smart_list.py", line 319, in __iter__
    yield self._parent[i]
  File "/home/yurik/.local/lib/python3.7/site-packages/mwparserfromhell/smart_list.py", line 96, in __getitem__
    return super(SmartList, self).__getitem__(key)
IndexError: list index out of range
nyurik commented 4 years ago

The issue was traced to incorrect slicing + iteration handling in smartlist. Closing in favor of #226