Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xhtml2pdf broken in python 3.8 - AttributeError: module 'cgi' has no attribute 'escape' #107

Open
sipposip opened this issue Mar 11, 2021 · 0 comments
Labels
bug Something isn't working CLI Regards the CLI

Comments

@sipposip
Copy link

When using the CLI with python 3.8, the following error occurs:

Traceback (most recent call last):
  File "c:\users\sscher\miniconda3\envs\ai-certification\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\sscher\miniconda3\envs\ai-certification\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\sscher\Miniconda3\envs\ai-certification\Scripts\aequitas-report.exe\__main__.py", line 7, in <module>
  File "c:\users\sscher\miniconda3\envs\ai-certification\lib\site-packages\aequitas_cli\aequitas_audit.py", line 235, in main
    push_topdf(args.input_file, report)
  File "c:\users\sscher\miniconda3\envs\ai-certification\lib\site-packages\aequitas_cli\utils\io.py", line 97, in push_topdf
    pisaStatus = pisa.CreatePDF(report, dest=result_pdf)
  File "c:\users\sscher\miniconda3\envs\ai-certification\lib\site-packages\xhtml2pdf\document.py", line 136, in pisaDocument
    doc.build(context.story)
  File "c:\users\sscher\miniconda3\envs\ai-certification\lib\site-packages\reportlab\platypus\doctemplate.py", line 1080, in build
    self.handle_flowable(flowables)
  File "c:\users\sscher\miniconda3\envs\ai-certification\lib\site-packages\reportlab\platypus\doctemplate.py", line 932, in handle_flowable
    self.afterFlowable(f)
  File "c:\users\sscher\miniconda3\envs\ai-certification\lib\site-packages\xhtml2pdf\xhtml2pdf_reportlab.py", line 122, in afterFlowable
    cgi.escape(copy.deepcopy(flowable.text), 1),
AttributeError: module 'cgi' has no attribute 'escape'

It is due to a problem in xhtml2pdf which uses cgi.escape, which has been removed in python 3.8. This is a known issue in xthml2pdf which has not yet been fixed (xhtml2pdf/xhtml2pdf#501)
workaround solution: downgrade to python 3.7

@sgpjesus sgpjesus added bug Something isn't working CLI Regards the CLI labels Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working CLI Regards the CLI
Projects
None yet
Development

No branches or pull requests

2 participants