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

refactor: Create a copy of settings on Builder.write_doctree() #10431

Merged
merged 1 commit into from May 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 4 additions & 5 deletions sphinx/builders/__init__.py
Expand Up @@ -476,11 +476,6 @@ def read_doc(self, docname: str) -> None:
publisher.publish()
doctree = publisher.document

# The settings object is reused by the Publisher for each document.
# Becuase we modify the settings object in ``write_doctree``, we
# need to ensure that each doctree has an independent copy.
doctree.settings = doctree.settings.copy()

# store time of reading, for outdated files detection
# (Some filesystems have coarse timestamp resolution;
# therefore time.time() can be older than filesystem's timestamp.
Expand All @@ -499,6 +494,10 @@ def write_doctree(self, docname: str, doctree: nodes.document) -> None:
# make it picklable
doctree.reporter = None
doctree.transformer = None

# Create a copy of settings object before modification because it is
# shared with other documents.
doctree.settings = doctree.settings.copy()
doctree.settings.warning_stream = None
doctree.settings.env = None
doctree.settings.record_dependencies = None
Expand Down