mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #4532 from dpizetta/1.7-release
Fix #4019: exception treatment for AttributeError stopping make process
This commit is contained in:
commit
48b4c373f3
1
AUTHORS
1
AUTHORS
@ -73,6 +73,7 @@ Other contributors, listed alphabetically, are:
|
|||||||
* Joel Wurtz -- cellspanning support in LaTeX
|
* Joel Wurtz -- cellspanning support in LaTeX
|
||||||
* Hong Xu -- svg support in imgmath extension and various bug fixes
|
* Hong Xu -- svg support in imgmath extension and various bug fixes
|
||||||
* Stephen Finucane -- setup command improvements and documentation
|
* Stephen Finucane -- setup command improvements and documentation
|
||||||
|
* Daniel Pizetta -- inheritance diagram improvements
|
||||||
|
|
||||||
Many thanks for all contributions!
|
Many thanks for all contributions!
|
||||||
|
|
||||||
|
1
CHANGES
1
CHANGES
@ -15,6 +15,7 @@ Features added
|
|||||||
|
|
||||||
Bugs fixed
|
Bugs fixed
|
||||||
----------
|
----------
|
||||||
|
* #4019: inheritance_diagram AttributeError stoping make process
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
@ -75,14 +75,20 @@ def try_import(objname):
|
|||||||
try:
|
try:
|
||||||
__import__(objname)
|
__import__(objname)
|
||||||
return sys.modules.get(objname) # type: ignore
|
return sys.modules.get(objname) # type: ignore
|
||||||
except ImportError:
|
except (ImportError, ValueError): # ValueError,py27 -> ImportError,py3
|
||||||
modname, attrname = module_sig_re.match(objname).groups() # type: ignore
|
matched = module_sig_re.match(objname) # type: ignore
|
||||||
|
|
||||||
|
if not matched:
|
||||||
|
return None
|
||||||
|
|
||||||
|
modname, attrname = matched.groups()
|
||||||
|
|
||||||
if modname is None:
|
if modname is None:
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
__import__(modname)
|
__import__(modname)
|
||||||
return getattr(sys.modules.get(modname), attrname, None)
|
return getattr(sys.modules.get(modname), attrname, None)
|
||||||
except ImportError:
|
except (ImportError, ValueError): # ValueError,py27 -> ImportError,py3
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,6 +83,15 @@ def test_import_classes(rootdir):
|
|||||||
with pytest.raises(InheritanceException):
|
with pytest.raises(InheritanceException):
|
||||||
import_classes('unknown.Unknown', None)
|
import_classes('unknown.Unknown', None)
|
||||||
|
|
||||||
|
# got exception InheritanceException for wrong class or module
|
||||||
|
# not AttributeError (refs: #4019)
|
||||||
|
with pytest.raises(InheritanceException):
|
||||||
|
import_classes('unknown', '.')
|
||||||
|
with pytest.raises(InheritanceException):
|
||||||
|
import_classes('unknown.Unknown', '.')
|
||||||
|
with pytest.raises(InheritanceException):
|
||||||
|
import_classes('.', None)
|
||||||
|
|
||||||
# a module having no classes
|
# a module having no classes
|
||||||
classes = import_classes('sphinx', None)
|
classes = import_classes('sphinx', None)
|
||||||
assert classes == []
|
assert classes == []
|
||||||
|
Loading…
Reference in New Issue
Block a user