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

Remove unnecessary try/except around ETSConfig.provisional_toolkit #927

Closed
rahulporuri opened this issue Apr 12, 2021 · 0 comments · Fixed by #935
Closed

Remove unnecessary try/except around ETSConfig.provisional_toolkit #927

rahulporuri opened this issue Apr 12, 2021 · 0 comments · Fixed by #935
Labels
difficulty: easy Issues which don't need much/any context about the package. type: cleanup

Comments

@rahulporuri
Copy link
Contributor

try:
provisional_toolkit = ETSConfig.provisional_toolkit
except AttributeError:
from contextlib import contextmanager
# for backward compatibility
@contextmanager
def provisional_toolkit(toolkit_name):
""" Perform an operation with toolkit provisionally set
This sets the toolkit attribute of the ETSConfig object set to the
provided value. If the operation fails with an exception, the toolkit
is reset to nothing.
"""
if ETSConfig.toolkit:
raise AttributeError("ETSConfig toolkit is already set")
ETSConfig.toolkit = toolkit_name
try:
yield
except:
# reset the toolkit state
ETSConfig._toolkit = ""
raise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: easy Issues which don't need much/any context about the package. type: cleanup
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant