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

Sphinx 2.4.1 - Unable to use rst2pdf #7151

Closed
Culip opened this issue Feb 14, 2020 · 1 comment
Closed

Sphinx 2.4.1 - Unable to use rst2pdf #7151

Culip opened this issue Feb 14, 2020 · 1 comment

Comments

@Culip
Copy link

Culip commented Feb 14, 2020

Describe the bug
I regularly have exported PDF using rst2pdf in the past few months. I upgraded Sphinx from 2.3 to 2.4.1. Since then, the following command no longer works:

sphinx-build -b pdf /home/sarah/sphinxProject/source/ /home/sarah/sphinxProject/build/

Expected behavior. A PDF file shall be created under the build directory.

Actual behavior. I get the following error instead:

Traceback (most recent call last):
  File "/home/sarah/sphinxProject/env/lib64/python3.6/site-packages/rst2pdf/pdfbuilder.py", line 216, in assemble_doctree
    self.env.indexentries={docname:self.env.indexentries[docname+'-gen']}
KeyError: 'index-gen'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sarah/sphinxProject/env/lib64/python3.6/site-packages/rst2pdf/pdfbuilder.py", line 141, in write
    appendices=opts.get('pdf_appendices', self.config.pdf_appendices) or [])
  File "/home/sarah/sphinxProject/env/lib64/python3.6/site-packages/rst2pdf/pdfbuilder.py", line 218, in assemble_doctree
    self.env.indexentries={}
AttributeError: can't set attribute
FAILED
build succeeded.

I created a new Sphinx 2.4.1 environment and I was able to reproduce the same issue.

To Reproduce

$ mkdir sphinxTest
$ cd    sphinxTest
$ python3 -m pip install --user virtualenv
$ pip install --user --upgrade pip
$ python3 -m venv env
$ source ./env/bin/activate
(env) pip install --upgrade pip
(env) pip install -U sphinx
(env) sphinx-quickstart
(env) make html     # Confirmed the HTML version was created with no issues.
(env) pip install rst2pdf
(env) vi ./source/conf.py

Add the lines in {{./source/conf.py}}

extensions = ['rst2pdf.pdfbuilder']

pdf_documents = [(
    'index',
    u'testRst2Pdf',
    u'Test Title',
    u'Sarah Author')]

Save it and go back to the shell.

(env) sphinx-build -b pdf ./source/ ./build/
Running Sphinx v2.4.1
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date
building [pdf]: targets for 1 source files that are out of date
updating environment: 0 added, 0 changed, 0 removed
looking for now-outdated files... none found
processing testRst2Pdf...
index
[ERROR] pdfbuilder.py:149 can't set attribute
Traceback (most recent call last):
  File "/home/sarah/sphinxTest/env/lib64/python3.6/site-packages/rst2pdf/pdfbuilder.py", line 216, in assemble_doctree
    self.env.indexentries={docname:self.env.indexentries[docname+'-gen']}
KeyError: 'index-gen'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sarah/sphinxTest/env/lib64/python3.6/site-packages/rst2pdf/pdfbuilder.py", line 141, in write
    appendices=opts.get('pdf_appendices', self.config.pdf_appendices) or [])
  File "/home/sarah/sphinxTest/env/lib64/python3.6/site-packages/rst2pdf/pdfbuilder.py", line 218, in assemble_doctree
    self.env.indexentries={}
AttributeError: can't set attribute
FAILED
build succeeded.
(env)

Expected behavior
A PDF file should be created under the output target (build).

Your project
N/A

Screenshots
N/A

Environment info

  • OS: Linux centos 3.10.0-1062.12.1 x86_64
  • Python version: 3.6.8
  • Sphinx version: 2.4.1
  • Sphinx extensions: ['rst2pdf.pdfbuilder']
  • Extra tools: N/A

Additional context
N/A

@Culip Culip added the type:bug label Feb 14, 2020
tk0miya added a commit to tk0miya/sphinx that referenced this issue Feb 15, 2020
@tk0miya tk0miya added this to the 2.4.2 milestone Feb 15, 2020
tk0miya added a commit to tk0miya/sphinx that referenced this issue Feb 16, 2020
tk0miya added a commit that referenced this issue Feb 16, 2020
Fix #7151: crashed when extension assigns a value to env.indexentries
@tk0miya
Copy link
Member

tk0miya commented Feb 16, 2020

Fixed by #7158
Thank you for reporting.

@tk0miya tk0miya closed this as completed Feb 16, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants