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

sphinxcontrib.youtube incompatibility at 6.1.2: can only concatenate str (not "PosixPath") to str #11115

Closed
akshay-joshi opened this issue Jan 9, 2023 · 8 comments
Milestone

Comments

@akshay-joshi
Copy link

Describe the bug

Hi

We are getting the 'can only concatenate str (not "PosixPath") to str' error when building pgAdmin's documentation. Till 6.1.1 everything is working fine, but with the latest version 6.1.2, our builds are started failing with below error:

copying images... [ 58%] images/procedure_sql.png
Exception occurred:
File "/Users/akshayjoshi/Developement/venv_psy2/lib/python3.10/site-packages/sphinx/util/console.py", line 86, in colorize
return escseq(name) + text + escseq('reset')
TypeError: can only concatenate str (not "PosixPath") to str
The full traceback has been saved in /var/folders/31/fyp66yh91vb7vys5xypw10qc0000gn/T/sphinx-err-wm4y0m72.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!
make[1]: *** [html] Error 2
make: *** [docs] Error 2

How to Reproduce

Uploading Screenshot 2023-01-09 at 10.31.59 AM.png…

Environment Information

Platform:              darwin; (macOS-12.6-x86_64-i386-64bit)
Python version:        3.10.2 (v3.10.2:a58ebcc701, Jan 13 2022, 14:50:16) [Clang 13.0.0 (clang-1300.0.29.30)])
Python implementation: CPython
Sphinx version:        6.1.2
Docutils version:      0.19
Jinja2 version:        3.1.2
Pygments version:      2.13.0

Sphinx extensions

No response

Additional context

No response

@jfbu
Copy link
Contributor

jfbu commented Jan 9, 2023

Reproduced with this trace:

# Platform:         darwin; (macOS-10.13.6-x86_64-i386-64bit)
# Sphinx version:   6.2.0+/e5bdb9378
# Python version:   3.10.9 (CPython)
# Docutils version: 0.19
# Jinja2 version:   3.1.2
# Pygments version: 2.14.0

# Last messages:
#   Copie des images... [ 56%] images/primary_key_general.png
#   Copie des images... [ 57%] images/primary_key_definition.png
#   Copie des images... [ 57%] images/primary_key_sql.png
#   Copie des images... [ 57%] images/procedure_general.png
#   Copie des images... [ 57%] images/procedure_definition.png
#   Copie des images... [ 58%] images/procedure_code.png
#   Copie des images... [ 58%] images/procedure_options.png
#   Copie des images... [ 58%] images/procedure_parameters.png
#   Copie des images... [ 58%] images/procedure_security.png
#   Copie des images... [ 59%] images/procedure_sql.png

# Loaded extensions:
#   sphinx.ext.mathjax (6.2.0+/e5bdb9378)
#   sphinxcontrib.applehelp (1.0.3)
#   sphinxcontrib.devhelp (1.0.2)
#   sphinxcontrib.htmlhelp (2.0.0)
#   sphinxcontrib.serializinghtml (1.1.5)
#   sphinxcontrib.qthelp (1.0.3)
#   alabaster (0.7.12)
#   sphinxcontrib.youtube (unknown version)

# Traceback:
Traceback (most recent call last):
  File "/Users/johndoe/_gits/sphinx/sphinx/cmd/build.py", line 284, in build_main
    app.build(args.force_all, args.filenames)
  File "/Users/johndoe/_gits/sphinx/sphinx/application.py", line 347, in build
    self.builder.build_update()
  File "/Users/johndoe/_gits/sphinx/sphinx/builders/__init__.py", line 311, in build_update
    self.build(to_build,
  File "/Users/johndoe/_gits/sphinx/sphinx/builders/__init__.py", line 380, in build
    self.finish()
  File "/Users/johndoe/_gits/sphinx/sphinx/builders/html/__init__.py", line 684, in finish
    self.finish_tasks.add_task(self.copy_image_files)
  File "/Users/johndoe/_gits/sphinx/sphinx/util/parallel.py", line 38, in add_task
    res = task_func()
  File "/Users/johndoe/_gits/sphinx/sphinx/builders/html/__init__.py", line 770, in copy_image_files
    for src in status_iterator(self.env.images, __('copying images... '), "brown",
  File "/Users/johndoe/_gits/sphinx/sphinx/util/display.py", line 38, in status_iterator
    item_str = colorize(color, stringify_func(item))
  File "/Users/johndoe/_gits/sphinx/sphinx/util/console.py", line 86, in colorize
    return escseq(name) + text + escseq('reset')
TypeError: can only concatenate str (not "PosixPath") to str

It appears self.env.images contains PosixPath('_video_thumbnail/jjP6O_xuHxE.jpg'): ({''}, 'jjP6O_xuHxE.jpg') and addition of this key-value is done by sphinxcontrib.youtube.utils.Video.run().

a1cd19e is the first bad commit

@jfbu jfbu added this to the 6.1.3 milestone Jan 9, 2023
@AA-Turner
Copy link
Member

It appears self.env.images contains PosixPath('_video_thumbnail/jjP6O_xuHxE.jpg'): ({''}, 'jjP6O_xuHxE.jpg') and addition of this key-value is done by sphinxcontrib.youtube.utils.Video.run().

sphinxcontrib.youtube should be fixed, we don't support pathlib types internally.

A

@jfbu jfbu removed this from the 6.1.3 milestone Jan 9, 2023
@jfbu
Copy link
Contributor

jfbu commented Jan 9, 2023

@AA-Turner removed label and milestone for now

@jfbu
Copy link
Contributor

jfbu commented Jan 9, 2023

@AA-Turner perhaps there is also other potential problem because I applied

diff --git a/sphinx/util/display.py b/sphinx/util/display.py
index 99b76599a..274c107e1 100644
--- a/sphinx/util/display.py
+++ b/sphinx/util/display.py
@@ -35,7 +35,11 @@ def status_iterator(
     if length == 0:
         logger.info(bold(summary), nonl=True)
     for i, item in enumerate(iterable, start=1):
-        item_str = colorize(color, stringify_func(item))
+        if not isinstance(item, str):
+            logger.info(f"class {type(item)} but expected a 'str' object")
+            item_str = colorize(color, stringify_func(str(item)))
+        else:
+            item_str = colorize(color, stringify_func(item))
         if length == 0:
             logger.info(item_str, nonl=True)
             logger.info(' ', nonl=True)

only for the make html to complete and I get this (after removing -W from their sphinx-build):

Downloading remote images...[100%] https://i3.ytimg.com/vi/jjP6O_xuHxE/maxresdefhttps://i3.ytimg.com/vi/jjP6O_xuHxE/maxresdefault.jpg -> /Users/path/to/pgadmin4/docs/en_US/_build/html/_video_thumbnail/jjP6O_xuHxE.jpg (already in cache)

Recherche des fichiers périmés... aucun résultat
Environnement de sérialisation... fait
Vérification de la cohérence... fait
Document en préparation... fait
Écriture... [100%] webserver                                                   
Génération des index... genindex fait
Écriture des pages additionnelles... search fait
class <class 'pathlib.PosixPath'> but expected a 'str' object                  

so far so good but then

WARNING: impossible de copier le fichier image '/Users/path/to/pgadmin4/docs/en_US/_video_thumbnail/jjP6O_xuHxE.jpg': [Errno 2] No such file or directory: '/Users/path/to/pgadmin4/docs/en_US/_video_thumbnail/jjP6O_xuHxE.jpg'
Copie des images... [100%] images/viewdata_filter_dialog.png                   
Copie des fichiers statiques... fait
Copie des fichiers complémentaires... fait
Export de l'index de recherche en English (code: en)... fait
Export de l'inventaire des objets... fait
La compilation a réussi, 1 avertissement.

Les pages HTML sont dans _build/html.

Build finished. The HTML pages are in _build/html.

It looks for the file '/Users/path/to/pgadmin4/docs/en_US/_video_thumbnail/jjP6O_xuHxE.jpg but only /Users/path/to/pgadmin4/docs/en_US/_build/html/_video_thumbnail/jjP6O_xuHxE.jpg is available from the action of sphinxcontrib.youtube.

Or perhaps this is only indicative of more extensive change needed at sphinxcontrib.youtube?

@jfbu jfbu added the extensions label Jan 9, 2023
@akshay-joshi
Copy link
Author

All,

With version 6.1.1, Build is successful with the following logs, so for our release, we have pinned the version to 6.1.1

Running Sphinx v6.1.1
making output directory... done
building [mo]: targets for 0 po files that are out of date
writing output... 
building [html]: targets for 195 source files that are out of date
updating environment: [new config] 195 added, 0 changed, 0 removed
reading sources... [100%] webserver                                                                                                                                                                  
https://i3.ytimg.com/vi/jjP6O_xuHxE/maxresdefault.jpg -> /Users/akshayjoshi/Developement/pgadmin4/docs/en_US/_build/html/_video_thumbnail/jjP6O_xuHxE.jpg (downloading)                              

looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] webserver                                                                                                                                                                   
generating indices... genindex done
writing additional pages... search done
copying images... [100%] images/viewdata_filter_dialog.png                                                                                                                                           
copying static files... done
copying extra files... done
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded.

The HTML pages are in _build/html.

Build finished. The HTML pages are in _build/html.

@jfbu
Copy link
Contributor

jfbu commented Jan 9, 2023

Minimal reproducer

index.rst:

Welcome to FOO's documentation!
===============================

Watch the demo
**************

.. youtube:: jjP6O_xuHxE
    :align: center
    :width: 800

and in conf.py:

extensions = ["sphinxcontrib.youtube"]

@jfbu jfbu changed the title can only concatenate str (not "PosixPath") to str sphinxcontrib.youtube incompatibility since 6.1.2: can only concatenate str (not "PosixPath") to str Jan 9, 2023
@AA-Turner
Copy link
Member

I have released v6.1.3 which should fix this by reverting the parallel image changes.

A

@jfbu jfbu changed the title sphinxcontrib.youtube incompatibility since 6.1.2: can only concatenate str (not "PosixPath") to str sphinxcontrib.youtube incompatibility at 6.1.2: can only concatenate str (not "PosixPath") to str Jan 10, 2023
@jfbu jfbu added this to the 6.1.3 milestone Jan 10, 2023
@jfbu
Copy link
Contributor

jfbu commented Jan 10, 2023

I will close this for time being on our side as the issue is not present with Shinx 6.1.3. Revert of parallel image changes happened at 2a7c40d.

Relates #11100

@jfbu jfbu closed this as completed Jan 10, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 10, 2023
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

3 participants