summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2021-02-16 20:38:12 +0900
committerGitHub <noreply@github.com>2021-02-16 20:38:12 +0900
commite2bef2d1d24b62f445f823d76106c38cd67e63ae (patch)
treed73bb0917156320d18e2210a1acbeea988acf102
parent66539af2f41b44f34898b1312cdc187ddf066f62 (diff)
parentb29ee3ded00de1d3ddc6547b171f091374a71e47 (diff)
downloadsphinx-git-e2bef2d1d24b62f445f823d76106c38cd67e63ae.tar.gz
Merge pull request #8896 from tk0miya/8883_AttributeError_assigning_annotations
Fix #8883: autodoc: AttributeError on assigning __annotations__
-rw-r--r--CHANGES2
-rw-r--r--sphinx/ext/autodoc/__init__.py6
2 files changed, 5 insertions, 3 deletions
diff --git a/CHANGES b/CHANGES
index f666a5b16..de4709dfb 100644
--- a/CHANGES
+++ b/CHANGES
@@ -16,6 +16,8 @@ Features added
Bugs fixed
----------
+* #8883: autodoc: AttributeError is raised on assigning __annotations__ on
+ read-only class
* #8884: html: minified js stemmers not included in the distributed package
* #8885: html: AttributeError is raised if CSS/JS files are installed via
:confval:`html_context`
diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py
index dc413b5c2..3ae6dff75 100644
--- a/sphinx/ext/autodoc/__init__.py
+++ b/sphinx/ext/autodoc/__init__.py
@@ -1394,7 +1394,7 @@ class FunctionDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # typ
params[0] = params[0].replace(annotation=typ)
try:
func.__signature__ = sig.replace(parameters=params) # type: ignore
- except TypeError:
+ except (AttributeError, TypeError):
# failed to update signature (ex. built-in or extension types)
return
@@ -2177,7 +2177,7 @@ class MethodDocumenter(DocstringSignatureMixin, ClassLevelDocumenter): # type:
params[1] = params[1].replace(annotation=typ)
try:
func.__signature__ = sig.replace(parameters=params) # type: ignore
- except TypeError:
+ except (AttributeError, TypeError):
# failed to update signature (ex. built-in or extension types)
return
@@ -2443,7 +2443,7 @@ class AttributeDocumenter(GenericAliasMixin, NewTypeMixin, SlotsMixin, # type:
annotations[attrname] = annotation
except (AttributeError, PycodeError):
pass
- except TypeError:
+ except (AttributeError, TypeError):
# Failed to set __annotations__ (built-in, extensions, etc.)
pass