diff --git a/CHANGES b/CHANGES index 5ad1c3ece..d0f5c2875 100644 --- a/CHANGES +++ b/CHANGES @@ -13,6 +13,8 @@ Features added Bugs fixed ---------- +* #3597: python domain raises UnboundLocalError if invalid name given + Testing -------- diff --git a/sphinx/domains/python.py b/sphinx/domains/python.py index a6c223d89..11fa719dc 100644 --- a/sphinx/domains/python.py +++ b/sphinx/domains/python.py @@ -302,6 +302,7 @@ class PyObject(ObjectDescription): only the most recent object is tracked. This object prefix name will be removed with :py:meth:`after_content`. """ + prefix = None if self.names: # fullname and name_prefix come from the `handle_signature` method. # fullname represents the full object name that is constructed using @@ -312,8 +313,6 @@ class PyObject(ObjectDescription): prefix = fullname elif name_prefix: prefix = name_prefix.strip('.') - else: - prefix = None if prefix: self.env.ref_context['py:class'] = prefix if self.allow_nesting: