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

Fix #4019: exception treatment for AttributeError stopping make process #4532

Merged
merged 6 commits into from
Feb 2, 2018
Merged

Fix #4019: exception treatment for AttributeError stopping make process #4532

merged 6 commits into from
Feb 2, 2018

Conversation

dpizetta
Copy link
Contributor

@dpizetta dpizetta commented Jan 31, 2018

Subject: AttributeError/ValueError exceptions are stopping make process

Feature or Bugfix

  • Bugfix

Purpose

  • These should not stop make process, after all, the warning about missing module is still showed.

Detail

  • Insert treatment for attribute error when trying to get group attribute from a None object. It is caused by a not found module name inserted in inheritance diagram.
  • Add author
  • Add changes
  • Add tests
  • Catch ValueError when importing for compatibility with Python 2.7 (ImportError for Python 3)

Relates

Copy link
Member

@tk0miya tk0miya left a 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?

return getattr(sys.modules.get(modname), attrname, None)
except ImportError:
modname, attrname = module_sig_re.match(objname).groups() # type: ignore
except AttributeError:
Copy link
Member

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()
...

Copy link
Contributor Author

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.

@tk0miya tk0miya added this to the 1.7 milestone Feb 1, 2018
@dpizetta
Copy link
Contributor Author

dpizetta commented Feb 1, 2018

It should be ok now. Those test will fail with no fixed version and passes from now. Tks

@dpizetta
Copy link
Contributor Author

dpizetta commented Feb 1, 2018

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:

...
except (ImporError, ValueError): 
...

@tk0miya
Copy link
Member

tk0miya commented Feb 2, 2018

+1 for catching ValueError!

@tk0miya tk0miya merged commit 48b4c37 into sphinx-doc:1.7-release Feb 2, 2018
@tk0miya
Copy link
Member

tk0miya commented Feb 2, 2018

Thank you for your contribution!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants