Open crazyscientist opened 2 weeks ago
Thanks @crazyscientist - could you try to narrow down a more-minimal repro case for this? It seems that lxml
and sphinx.ext.viewcode
will be required -- and something, presumably extension-related, must be adding a reference to lxml
in the BuildEnvironment
.. but I can't figure out where yet.
Hi @jayaddison , thank you for the encouragement.
I managed to find the culprit and create a shorter example: https://gist.github.com/crazyscientist/7d53d148efc9cbe8d48756bf25c8fc3d
Steps to reproduce the problem with this gist:
models.py
) from the gistSphinx
and lxml
sphinx-quickstart
)source_conf.py
-> source/conf.py
source_index.rst
-> source/index.rst
make html
(which will cause the pickling error)No errors will be raised, if
sphinx.ext.viewcode
is removed from the extensions listmodels.py
is commented outOk, getting closer - thanks @crazyscientist! Does an error continue to occur if ObjectifiedElement
is -- separately -- removed? (indepdently from the L11 commenting-out)
(apologies for not actually testing that yet myself.. I may try to soon, but have gotten into too many separate tasks/threads recently)
@jayaddison No worries, happy to help out :slightly_smiling_face:
If I remove ObjectifiedElement
(both, in the import statement and type annotation), the error message does not change.
If there is an instance of ElementMaker
in the file, the exception will be raised. Otherwise, the docs get built as expected.
I don't know whether it is worth noting: Only commenting out line 11, in which ElementMaker()
is initialized, allows the docs to be built. The import of ElementMaker
in line 8 does not seem to cause a problem.
Enabling the autodoc
and viewcode
extensions, assigning a single module-level ElementMaker
variable, and then attempting to autodata
-document that variable seems to be enough to replicate this.
The part of the BuildEnvironment
that seems to be failing to pickle is the _viewcode_modules
attribute.. and in particular a modname
that is in fact an lxml.objectify._ObjectifyElementMakerCaller
object, not a string as the code seems designed for.
That's created/returned somewhere around here: https://github.com/sphinx-doc/sphinx/blob/a1510de4777eaa2e569435f95b05f6f3293d7035/sphinx/ext/viewcode.py#L57-L64
:notebook: For anyone investigating this: the --pdb
command-line option for sphinx-build
is quite useful!
Describe the bug
For our project, we have both the
autodoc
andviewcode
extensions enabled, and the project makes heavy use oflxml
.When building the docs, a
TypeError: cannot pickle 'lxml.objectify._ObjectifyElementMakerCaller' object
occurs.Without deeper analysis, a quick workaround is to disable the
viewcode
extension.How to Reproduce
Check out the project, install the dependencies and run Sphinx:
Environment Information
Sphinx extensions
Additional context
This is the full content of the log file generated