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

pep_html_translator.py throws an exception error when running sphinx-build with gettext .po files #3732

Open
hwhsu1231 opened this issue Mar 20, 2024 · 0 comments

Comments

@hwhsu1231
Copy link

hwhsu1231 commented Mar 20, 2024

Problem Description

Hello, PEPs Maintainance Team.

Recently, I tried to do a simple experiment of using sphinx-build to build PEPs with its gettext generated .po files.

However, I found that pep_html_translator.py will throw an exception error (even if I haven't translated the .po files yet):

Exception occurred:
  File "/home/hwhsu1231/Repo/peps/pep_sphinx_extensions/pep_processor/html/pep_html_translator.py", line 36, in should_be_compact_paragraph
    if any((key != "classes", not set(value) <= {"first", "last"})):
TypeError: 'bool' object is not iterable
The full traceback has been saved in /tmp/sphinx-err-o5nv3zch.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!

And it won't throw the above exception error if I don't use the gettext .po files to build it.

How to Reproduce

After downloading the demo.tar.gz file, run the following commands in order:

tar -xf demo.tar.gz
git clone https://github.com/python/peps.git
cd peps
git checkout ec21ce3471999e52645e7e43a59ec44c11443d54
mkdir -p peps/locale/
cp -r ../zh_TW/ ./peps/locale/
make venv
source .venv/bin/activate
LANG=en_US.UTF-8 sphinx-build -b html -D language=zh_TW -D locale_dirs=locale peps build
LANG=en_US.UTF-8 sphinx-build -b html peps build

See the full log below.

Version and Platform

  • OS version: Kubuntu 22.04
  • Python version: 3.10.12
  • PEPs commit: ec21ce3

Full log

Click to expand the full log
hwhsu1231@vb-kubuntu:~/Repo$ tar -xf demo.tar.gz
hwhsu1231@vb-kubuntu:~/Repo$ git clone https://github.com/python/peps.git
Cloning into 'peps'...
remote: Enumerating objects: 37847, done.
remote: Counting objects: 100% (4599/4599), done.
remote: Compressing objects: 100% (519/519), done.
remote: Total 37847 (delta 3498), reused 4341 (delta 3432), pack-reused 33248
Receiving objects: 100% (37847/37847), 30.04 MiB | 3.93 MiB/s, done.
Resolving deltas: 100% (24250/24250), done.
hwhsu1231@vb-kubuntu:~/Repo$ cd peps
hwhsu1231@vb-kubuntu:~/Repo/peps$ git checkout ec21ce3471999e52645e7e43a59ec44c11443d54
Note: switching to 'ec21ce3471999e52645e7e43a59ec44c11443d54'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at ec21ce34 PEP 667: Remove open issues section, as the issues have been resolved (#3731)
hwhsu1231@vb-kubuntu:~/Repo/peps$ mkdir -p peps/locale/
hwhsu1231@vb-kubuntu:~/Repo/peps$ cp -r ../zh_TW/ ./peps/locale/
hwhsu1231@vb-kubuntu:~/Repo/peps$ make venv
Creating venv in .venv
Requirement already satisfied: pip in ./.venv/lib/python3.10/site-packages (22.0.2)
Collecting pip
  Using cached pip-24.0-py3-none-any.whl (2.1 MB)
Collecting wheel
  Using cached wheel-0.43.0-py3-none-any.whl (65 kB)
Installing collected packages: wheel, pip
  Attempting uninstall: pip
    Found existing installation: pip 22.0.2
    Uninstalling pip-22.0.2:
      Successfully uninstalled pip-22.0.2
Successfully installed pip-24.0 wheel-0.43.0
Collecting Pygments>=2.9.0 (from -r requirements.txt (line 2))
  Using cached pygments-2.17.2-py3-none-any.whl.metadata (2.6 kB)
Collecting Sphinx!=6.1.0,!=6.1.1,>=5.1.1 (from -r requirements.txt (line 5))
  Using cached sphinx-7.2.6-py3-none-any.whl.metadata (5.9 kB)
Collecting docutils>=0.19.0 (from -r requirements.txt (line 6))
  Using cached docutils-0.20.1-py3-none-any.whl.metadata (2.8 kB)
Collecting sphinx-autobuild (from -r requirements.txt (line 8))
  Using cached sphinx_autobuild-2024.2.4-py3-none-any.whl.metadata (8.8 kB)
Collecting pytest (from -r requirements.txt (line 11))
  Using cached pytest-8.1.1-py3-none-any.whl.metadata (7.6 kB)
Collecting pytest-cov (from -r requirements.txt (line 12))
  Using cached pytest_cov-4.1.0-py3-none-any.whl.metadata (26 kB)
Collecting sphinxcontrib-applehelp (from Sphinx!=6.1.0,!=6.1.1,>=5.1.1->-r requirements.txt (line 5))
  Using cached sphinxcontrib_applehelp-1.0.8-py3-none-any.whl.metadata (2.3 kB)
Collecting sphinxcontrib-devhelp (from Sphinx!=6.1.0,!=6.1.1,>=5.1.1->-r requirements.txt (line 5))
  Using cached sphinxcontrib_devhelp-1.0.6-py3-none-any.whl.metadata (2.3 kB)
Collecting sphinxcontrib-jsmath (from Sphinx!=6.1.0,!=6.1.1,>=5.1.1->-r requirements.txt (line 5))
  Using cached sphinxcontrib_jsmath-1.0.1-py2.py3-none-any.whl.metadata (1.4 kB)
Collecting sphinxcontrib-htmlhelp>=2.0.0 (from Sphinx!=6.1.0,!=6.1.1,>=5.1.1->-r requirements.txt (line 5))
  Using cached sphinxcontrib_htmlhelp-2.0.5-py3-none-any.whl.metadata (2.3 kB)
Collecting sphinxcontrib-serializinghtml>=1.1.9 (from Sphinx!=6.1.0,!=6.1.1,>=5.1.1->-r requirements.txt (line 5))
  Using cached sphinxcontrib_serializinghtml-1.1.10-py3-none-any.whl.metadata (2.4 kB)
Collecting sphinxcontrib-qthelp (from Sphinx!=6.1.0,!=6.1.1,>=5.1.1->-r requirements.txt (line 5))
  Using cached sphinxcontrib_qthelp-1.0.7-py3-none-any.whl.metadata (2.2 kB)
Collecting Jinja2>=3.0 (from Sphinx!=6.1.0,!=6.1.1,>=5.1.1->-r requirements.txt (line 5))
  Using cached Jinja2-3.1.3-py3-none-any.whl.metadata (3.3 kB)
Collecting snowballstemmer>=2.0 (from Sphinx!=6.1.0,!=6.1.1,>=5.1.1->-r requirements.txt (line 5))
  Using cached snowballstemmer-2.2.0-py2.py3-none-any.whl.metadata (6.5 kB)
Collecting babel>=2.9 (from Sphinx!=6.1.0,!=6.1.1,>=5.1.1->-r requirements.txt (line 5))
  Using cached Babel-2.14.0-py3-none-any.whl.metadata (1.6 kB)
Collecting alabaster<0.8,>=0.7 (from Sphinx!=6.1.0,!=6.1.1,>=5.1.1->-r requirements.txt (line 5))
  Using cached alabaster-0.7.16-py3-none-any.whl.metadata (2.9 kB)
Collecting imagesize>=1.3 (from Sphinx!=6.1.0,!=6.1.1,>=5.1.1->-r requirements.txt (line 5))
  Using cached imagesize-1.4.1-py2.py3-none-any.whl.metadata (1.5 kB)
Collecting requests>=2.25.0 (from Sphinx!=6.1.0,!=6.1.1,>=5.1.1->-r requirements.txt (line 5))
  Using cached requests-2.31.0-py3-none-any.whl.metadata (4.6 kB)
Collecting packaging>=21.0 (from Sphinx!=6.1.0,!=6.1.1,>=5.1.1->-r requirements.txt (line 5))
  Using cached packaging-24.0-py3-none-any.whl.metadata (3.2 kB)
Collecting livereload (from sphinx-autobuild->-r requirements.txt (line 8))
  Using cached livereload-2.6.3-py2.py3-none-any.whl.metadata (7.4 kB)
Collecting colorama (from sphinx-autobuild->-r requirements.txt (line 8))
  Using cached colorama-0.4.6-py2.py3-none-any.whl.metadata (17 kB)
Collecting iniconfig (from pytest->-r requirements.txt (line 11))
  Using cached iniconfig-2.0.0-py3-none-any.whl.metadata (2.6 kB)
Collecting pluggy<2.0,>=1.4 (from pytest->-r requirements.txt (line 11))
  Using cached pluggy-1.4.0-py3-none-any.whl.metadata (4.3 kB)
Collecting exceptiongroup>=1.0.0rc8 (from pytest->-r requirements.txt (line 11))
  Using cached exceptiongroup-1.2.0-py3-none-any.whl.metadata (6.6 kB)
Collecting tomli>=1 (from pytest->-r requirements.txt (line 11))
  Using cached tomli-2.0.1-py3-none-any.whl.metadata (8.9 kB)
Collecting coverage>=5.2.1 (from coverage[toml]>=5.2.1->pytest-cov->-r requirements.txt (line 12))
  Using cached coverage-7.4.4-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (8.2 kB)
Collecting MarkupSafe>=2.0 (from Jinja2>=3.0->Sphinx!=6.1.0,!=6.1.1,>=5.1.1->-r requirements.txt (line 5))
  Using cached MarkupSafe-2.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (3.0 kB)
Collecting charset-normalizer<4,>=2 (from requests>=2.25.0->Sphinx!=6.1.0,!=6.1.1,>=5.1.1->-r requirements.txt (line 5))
  Using cached charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (33 kB)
Collecting idna<4,>=2.5 (from requests>=2.25.0->Sphinx!=6.1.0,!=6.1.1,>=5.1.1->-r requirements.txt (line 5))
  Using cached idna-3.6-py3-none-any.whl.metadata (9.9 kB)
Collecting urllib3<3,>=1.21.1 (from requests>=2.25.0->Sphinx!=6.1.0,!=6.1.1,>=5.1.1->-r requirements.txt (line 5))
  Using cached urllib3-2.2.1-py3-none-any.whl.metadata (6.4 kB)
Collecting certifi>=2017.4.17 (from requests>=2.25.0->Sphinx!=6.1.0,!=6.1.1,>=5.1.1->-r requirements.txt (line 5))
  Using cached certifi-2024.2.2-py3-none-any.whl.metadata (2.2 kB)
Collecting six (from livereload->sphinx-autobuild->-r requirements.txt (line 8))
  Using cached six-1.16.0-py2.py3-none-any.whl.metadata (1.8 kB)
Collecting tornado (from livereload->sphinx-autobuild->-r requirements.txt (line 8))
  Using cached tornado-6.4-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (2.5 kB)
Using cached pygments-2.17.2-py3-none-any.whl (1.2 MB)
Using cached sphinx-7.2.6-py3-none-any.whl (3.2 MB)
Using cached docutils-0.20.1-py3-none-any.whl (572 kB)
Using cached sphinx_autobuild-2024.2.4-py3-none-any.whl (10.0 kB)
Using cached pytest-8.1.1-py3-none-any.whl (337 kB)
Using cached pytest_cov-4.1.0-py3-none-any.whl (21 kB)
Using cached alabaster-0.7.16-py3-none-any.whl (13 kB)
Using cached Babel-2.14.0-py3-none-any.whl (11.0 MB)
Using cached coverage-7.4.4-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (233 kB)
Using cached exceptiongroup-1.2.0-py3-none-any.whl (16 kB)
Using cached imagesize-1.4.1-py2.py3-none-any.whl (8.8 kB)
Using cached Jinja2-3.1.3-py3-none-any.whl (133 kB)
Using cached packaging-24.0-py3-none-any.whl (53 kB)
Using cached pluggy-1.4.0-py3-none-any.whl (20 kB)
Using cached requests-2.31.0-py3-none-any.whl (62 kB)
Using cached snowballstemmer-2.2.0-py2.py3-none-any.whl (93 kB)
Using cached sphinxcontrib_htmlhelp-2.0.5-py3-none-any.whl (99 kB)
Using cached sphinxcontrib_serializinghtml-1.1.10-py3-none-any.whl (92 kB)
Using cached tomli-2.0.1-py3-none-any.whl (12 kB)
Using cached colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Using cached iniconfig-2.0.0-py3-none-any.whl (5.9 kB)
Using cached livereload-2.6.3-py2.py3-none-any.whl (24 kB)
Using cached sphinxcontrib_applehelp-1.0.8-py3-none-any.whl (120 kB)
Using cached sphinxcontrib_devhelp-1.0.6-py3-none-any.whl (83 kB)
Using cached sphinxcontrib_jsmath-1.0.1-py2.py3-none-any.whl (5.1 kB)
Using cached sphinxcontrib_qthelp-1.0.7-py3-none-any.whl (89 kB)
Using cached certifi-2024.2.2-py3-none-any.whl (163 kB)
Using cached charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (142 kB)
Using cached idna-3.6-py3-none-any.whl (61 kB)
Using cached MarkupSafe-2.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (25 kB)
Using cached urllib3-2.2.1-py3-none-any.whl (121 kB)
Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Using cached tornado-6.4-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (435 kB)
Installing collected packages: snowballstemmer, urllib3, tornado, tomli, sphinxcontrib-serializinghtml, sphinxcontrib-qthelp, sphinxcontrib-jsmath, sphinxcontrib-htmlhelp, sphinxcontrib-devhelp, sphinxcontrib-applehelp, six, Pygments, pluggy, packaging, MarkupSafe, iniconfig, imagesize, idna, exceptiongroup, docutils, coverage, colorama, charset-normalizer, certifi, babel, alabaster, requests, pytest, livereload, Jinja2, Sphinx, pytest-cov, sphinx-autobuild
Successfully installed Jinja2-3.1.3 MarkupSafe-2.1.5 Pygments-2.17.2 Sphinx-7.2.6 alabaster-0.7.16 babel-2.14.0 certifi-2024.2.2 charset-normalizer-3.3.2 colorama-0.4.6 coverage-7.4.4 docutils-0.20.1 exceptiongroup-1.2.0 idna-3.6 imagesize-1.4.1 iniconfig-2.0.0 livereload-2.6.3 packaging-24.0 pluggy-1.4.0 pytest-8.1.1 pytest-cov-4.1.0 requests-2.31.0 six-1.16.0 snowballstemmer-2.2.0 sphinx-autobuild-2024.2.4 sphinxcontrib-applehelp-1.0.8 sphinxcontrib-devhelp-1.0.6 sphinxcontrib-htmlhelp-2.0.5 sphinxcontrib-jsmath-1.0.1 sphinxcontrib-qthelp-1.0.7 sphinxcontrib-serializinghtml-1.1.10 tomli-2.0.1 tornado-6.4 urllib3-2.2.1
The venv has been created in the .venv directory
hwhsu1231@vb-kubuntu:~/Repo/peps$ source .venv/bin/activate
(.venv) hwhsu1231@vb-kubuntu:~/Repo/peps$ LANG=en_US.UTF-8 sphinx-build -b html -D language=zh_TW -D locale_dirs=locale peps build
Running Sphinx v7.2.6
loading translations [zh_TW]... done
making output directory... done
loading intersphinx inventory from https://docs.python.org/3/objects.inv...
loading intersphinx inventory from https://packaging.python.org/en/latest/objects.inv...
loading intersphinx inventory from https://typing.readthedocs.io/en/latest/objects.inv...
loading intersphinx inventory from https://devguide.python.org/objects.inv...
loading intersphinx inventory from https://docs.python.org/3.11/objects.inv...
loading intersphinx inventory from https://docs.python.org/3.12/objects.inv...
building [html]: targets for 642 source files that are out of date
updating environment: [new config] 642 added, 0 changed, 0 removed
reading sources... [100%] topic/typing
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
copying assets... copying static files... done
copying extra files... done
done
writing output... [  0%] pep-0000
Exception occurred:
  File "/home/hwhsu1231/Repo/peps/pep_sphinx_extensions/pep_processor/html/pep_html_translator.py", line 36, in should_be_compact_paragraph
    if any((key != "classes", not set(value) <= {"first", "last"})):
TypeError: 'bool' object is not iterable
The full traceback has been saved in /tmp/sphinx-err-o5nv3zch.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
(.venv) hwhsu1231@vb-kubuntu:~/Repo/peps$ LANG=en_US.UTF-8 sphinx-build -b html peps build
Running Sphinx v7.2.6
loading intersphinx inventory from https://docs.python.org/3/objects.inv...
loading intersphinx inventory from https://packaging.python.org/en/latest/objects.inv...
loading intersphinx inventory from https://typing.readthedocs.io/en/latest/objects.inv...
loading intersphinx inventory from https://devguide.python.org/objects.inv...
loading intersphinx inventory from https://docs.python.org/3.11/objects.inv...
loading intersphinx inventory from https://docs.python.org/3.12/objects.inv...
building [html]: targets for 643 source files that are out of date
updating environment: [new config] 643 added, 0 changed, 0 removed
reading sources... [100%] topic/typing
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
copying assets... copying static files... done
copying extra files... done
done
writing output... [100%] topic/typing
/home/hwhsu1231/Repo/peps/peps/pep-0728.rst:396: WARNING: py:class reference target not found: typing.Never
generating indices... done
writing additional pages... done
copying images... [100%] pep-3147-1.png
dumping object inventory... done
build succeeded, 1 warning.

The HTML pages are in build.
(.venv) hwhsu1231@vb-kubuntu:~/Repo/peps$

sphinx-err-o5nv3zch.log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant