Defect in RML parsing hasNameConstant is not defined

16 views
Skip to first unread message

Ryan Konkul

unread,
Mar 11, 2022, 2:28:46 PM3/11/22
to reportlab-users
Hi, I found a bug with the rml parsing code. It looks like hasNameConstant is never defined. I reproduced in 3.6.7 but I still see the bug in 3.6.8 code.

  File "/virtualenv/cpm/lib/python3.9/site-packages/reportlab/lib/rl_safe_eval.py", line 267, in gen_none_node
    return ast.NameConstant(value=None) if hasNameConstant else ast.Name(id='None', ctx=ast.Load())
NameError: asUnicodeEx(<rlextra.rml2pdf.rml2pdf.EvaluateOp object at 0x7fd2638a1a60>,enc='utf8') error:  name 'hasNameConstant' is not defined

I believe the fix would be to change the line in gen_none_node to

 return ast.NameConstant(value=None) if hasattr(ast, 'NameConstant') else ast.Name(id='None', ctx=ast.Load())

Not sure if that's the right fix since I don't know what hasNameConstant used to look like, but this will at least fix the issue I see.

Here is a paste of rml that reproduces the issue

Thanks
Reply all
Reply to author
Forward
0 new messages