-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
misc #58
Conversation
still needs fixing for py3:
|
Current coverage is
|
Any idea how to fix this? The |
one workaround is from contextlib import contextmanager
@contextmanager
def closing(thing):
try:
yield thing
finally:
thing.close() but that's not a proper fix... if people use the normal closing syntax in their own code ( |
Sorry, no idea, I didn't even know about closing() before! |
Well in py2.7 the closing from contextmanager would do essentially what my comment above says. apparently this was deprecated in py3: |
Yes, I think we need to define exit() and enter(). I think this is the cleanest, most pythonic approach. Why are you reluctant? |
Ah yes indeed, this has been deprecated, but because we can use the with statement directly. But I guess the same problem will arise: without |
To keep compatibility with Python 2.7, you can maybe do something like this:
Then you can do |
A good tutorial on how to define enter and exit (I don't know if the API changed since then, it's an old article): http://effbot.org/zone/python-with-statement.htm |
Basically, it would be:
|
enhancement (all python versions) and bugfix (py3)
Hah I figured it out by reading all the docs for the different versions. Would've been quicker if I'd checked your new comments first 👍 |
Haha, yes this also happened to me, this is because you tried to fix this issue on your own (which is a quality actually) ;) Great job on this, this is way cleaner to write unit tests! |
Yeah it was nice how aiming to clean up StringIO led to introducing a new feature for |
Um... I'm not sure it's possible to use that for the urllib example, because it uses a callback, and I don't think we can use the
But this was also possible before (I just construct the tqdm object outside of the my_hook() function), so using |
The new |
close()
methods in testsmaxinterval
handled properly