-
Notifications
You must be signed in to change notification settings - Fork 31
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
Rely on Python 2.5+ context managers #155
Conversation
I think it's pulling in pulp 2 in the containers |
src/katello/repos.py
Outdated
except IOError: | ||
error = sys.exc_info()[1] # backward and forward compatible way to get the exception | ||
if error.errno == errno.ENOENT: | ||
return False |
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.
except IOError: | |
error = sys.exc_info()[1] # backward and forward compatible way to get the exception | |
if error.errno == errno.ENOENT: | |
return False | |
except IOError as exc: | |
if exc.errno == errno.ENOENT: | |
return False |
Should work on 2.7+
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.
What I don't get is why this is special-cased at all -- if there was an IOError, the cache is not valid.
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.
Actually, if there was any error/exception, it's not valid. The only difference the code right now makes is returning False
vs None
, but nobody cares about that.
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.
I wasn't quite sure about it and needing Python 2.6 at the time. Did we completely drop EL6 support, including in downstream?
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.
Updated to simplify. How about this version?
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.
RHEL6 is dead-dead-dead soon: https://access.redhat.com/articles/4665701
And those changes won't land downstream before that anyway.
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.
What's the soon part? I see since July 1st it's in a "we provide you with docs so you can upgrade" phase.
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.
oh, just realized it's july already :D
This removes a special case for ENOENT where it returned False, otherwise None. In practice this doesn't matter and is handled in the same way by callers.
In Python 2.5 context managers were added, which can help ensure open files are closed. EL 5 shipped with Python 2.4, but EL6 has Python 2.6 meaning we can now rely on this shiny new feature.
In Python 2.5 context managers were added, which can help ensure open files are closed. EL 5 shipped with Python 2.4, but EL6 has Python 2.6 meaning we can now rely on this shiny new feature.