-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Fix #4019: exception treatment for AttributeError stopping make process #4532
Conversation
Fix #4019: exception treatment for NoneType group attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a testcase please?
sphinx/ext/inheritance_diagram.py
Outdated
return getattr(sys.modules.get(modname), attrname, None) | ||
except ImportError: | ||
modname, attrname = module_sig_re.match(objname).groups() # type: ignore | ||
except AttributeError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this? It would be better to check the matched or not before calling group()
to me.
matched = module_sig_re.match(objname) # type: ignore
if not matched:
return None
modname, attrname = matched.groups()
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeh, really better :) And I will provide the test.
It should be ok now. Those test will fail with no fixed version and passes from now. Tks |
I notice the test fail for Python 2.7. In 2.7 it raises a ValueError for importing the module named "..unknown", but in Python 3 it raises ImportError. I believe the best solution is to catch both of them:
|
+1 for catching |
Thank you for your contribution! |
Subject: AttributeError/ValueError exceptions are stopping make process
Feature or Bugfix
Purpose
Detail
Relates