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 the famous WeakSet keyError bug #607
Conversation
Codecov Report
@@ Coverage Diff @@
## master #607 +/- ##
==========================================
- Coverage 98.87% 98.63% -0.24%
==========================================
Files 9 10 +1
Lines 709 731 +22
Branches 127 130 +3
==========================================
+ Hits 701 721 +20
- Misses 5 6 +1
- Partials 3 4 +1 |
v4.19.1...tqdm:v4.24.0 Until 4.20, it is ok. They changed the behavior of keyError. |
`auto` will be able to support alternative backends in future - tqdm@97a9393#commitcomment-29850169 - tqdm@97a9393#commitcomment-30466004 - related to tqdm#198
Hi! How is this PR going? Some of our users have come across another error when installing our app, Conan, due to the We would want to know if solving this issue will allow us to upgrade the dependency and solve both of them... or maybe we should downgrade Thanks! |
#460 is unrelated. I hope to get around to reviewing this PR and all my other backlog soon |
getting there... |
22e1e22
to
5aa5924
Compare
- fix `str.isnumeric` #605 - fix `WeakSet` `KeyError` #548, #553, #596 -> #607 - stop `tqdm_notebook` description truncation #582 -> #599 - include `unit_scale` for `rate` #608 - add `auto` -> nowarning `autonotebook` - add better postfix numeric formatting #621 - minor refactoring #609 -> #616 - update documentation - add unit tests - fix py26 CI
- fix `str.isnumeric` #605 - fix `WeakSet` `KeyError` #548, #553, #596 -> #607 - stop `tqdm_notebook` description truncation #582 -> #599 - include `unit_scale` for `rate` #608 - add `auto` -> nowarning `autonotebook` - add better postfix numeric formatting #621 - minor refactoring #609 -> #616 - update documentation - add unit tests - fix py26 CI
This PR fixes #596 #548 #553, by checking the existence of an
instance
before removing it fromtqdm._instances
(WeakSet)Another solution to fix them is to ignore the KeyError in the following code.
I think I almost find why this problem occurs.
@casperdcl See this
v4.19.1...tqdm:v4.24.0
It is highly possible that, the problem is because of this part in
_tqdm.py
In
v4.19
, when removing an instance from WeakSet, theKeyError
is ignored.Magically, now it will raise an error. (well, I don't have time to check why someone changes this to raise an error).
However, we can avoid this
keyError
.It seems in python2, when tqdm is called with for like this
py2 will magically collect the hidden object of trange(10) after break, which causes this
keyError
.I say this because this code works well.
So, it may happen that the tqdm._instances(WeakSet) does not know the
instance
is already removed, but it still try to remove the instance and causes the keyError. We can add a check step before the removal.