You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for catching this. Apparently Python compiles extensions (in my environment) with -DNDEBUG, so the assert wasn't triggering, and apparently PyList_GET_SIZE() works on dicts for some reason.
It should have been PyList_GET_SIZE(deflist), because the reference to defmap is dropped by that point.
The code is actually broken with all versions of Python. Older versions just silently tolerate it.
In
mwparserfromhell/parser/ctokenizer/tokenizer.c
,load_entities
function contains:So
defmap
is actuallyentitydefs
attribute inENTITYDEFS_MODULE
.mwparserfromhell/parser/ctokenizer/tokenizer.h
has:So with Python 2,
defmap
ishtmlentitydefs.entitydefs
, while with Python 3, it ishtml.entities.entitydefs
.As you can see in:
https://github.com/python/cpython/blob/2.7/Lib/htmlentitydefs.py
https://github.com/python/cpython/blob/3.6/Lib/html/entities.py
https://github.com/python/cpython/blob/3.7/Lib/html/entities.py
entitydefs
is a dict, not a list, soPyList_GET_SIZE
should not be used with it.In Python 3.6,
PyList_GET_SIZE
is defined:https://github.com/python/cpython/blob/3.6/Include/listobject.h
In Python 3.7,
PyList_GET_SIZE
is defined:https://github.com/python/cpython/blob/3.7/Include/listobject.h
See also:
https://bugs.python.org/issue29867
python/cpython@1a5856b
The text was updated successfully, but these errors were encountered: