{"action":"opened","number":607,"pull_request":{"url":"https://api.github.com/repos/tqdm/tqdm/pulls/607","id":214228498,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE0MjI4NDk4","html_url":"https://github.com/tqdm/tqdm/pull/607","diff_url":"https://github.com/tqdm/tqdm/pull/607.diff","patch_url":"https://github.com/tqdm/tqdm/pull/607.patch","issue_url":"https://api.github.com/repos/tqdm/tqdm/issues/607","number":607,"state":"open","locked":false,"title":"fix the famous WeakSet keyError bug ","user":{"login":"chengs","id":824529,"node_id":"MDQ6VXNlcjgyNDUyOQ==","avatar_url":"https://avatars2.githubusercontent.com/u/824529?v=4","gravatar_id":"","url":"https://api.github.com/users/chengs","html_url":"https://github.com/chengs","followers_url":"https://api.github.com/users/chengs/followers","following_url":"https://api.github.com/users/chengs/following{/other_user}","gists_url":"https://api.github.com/users/chengs/gists{/gist_id}","starred_url":"https://api.github.com/users/chengs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chengs/subscriptions","organizations_url":"https://api.github.com/users/chengs/orgs","repos_url":"https://api.github.com/users/chengs/repos","events_url":"https://api.github.com/users/chengs/events{/privacy}","received_events_url":"https://api.github.com/users/chengs/received_events","type":"User","site_admin":false},"body":"This PR fixes #596 #548 #553, by using ``Set`` instead of ``WeakSet`` for python2\r\n\r\nI think I almost find why this problem occurs.\r\n@casperdcl See this\r\nhttps://github.com/tqdm/tqdm/compare/v4.19.1...tqdm:v4.24.0\r\n\r\nIt is highly possible that, the problem is because of this part in ``_tqdm.py``\r\n<img width=\"1486\" alt=\"screen shot 2018-09-10 at 3 43 36 pm\" src=\"https://user-images.githubusercontent.com/824529/45283435-73b2c500-b510-11e8-8113-f632d9a2e74f.png\">\r\nIn ``v4.19``, when removing an instance from WeakSet, the ``KeyError`` is ignored.\r\nMagically, now it will raise an error. (well, I don't have time to check why someone changes this to raise an error).\r\n\r\nHowever, we can avoid this ``keyError``.\r\nIt seems in python2, when tqdm is called with for like this\r\n```python\r\nfor _ in trange(10):\r\n   break\r\n```\r\npy2 will magically collect the hidden object of trange(10) after break, which causes this ``keyError``.\r\nI say this because this code works well.\r\n```python\r\npbar = tqdm(range(10))\r\nfor i in pbar:\r\n    if i==2:\r\n        break\r\n```\r\n\r\nSo, 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 let ``Set`` to replace ``WeakSet`` so that, the ``instance`` will have a reference in ``Set`` and does not be collected by python2's garbage collecting system.\r\n\r\n","created_at":"2018-09-10T08:03:14Z","updated_at":"2018-09-10T08:03:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/tqdm/tqdm/pulls/607/commits","review_comments_url":"https://api.github.com/repos/tqdm/tqdm/pulls/607/comments","review_comment_url":"https://api.github.com/repos/tqdm/tqdm/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tqdm/tqdm/issues/607/comments","statuses_url":"https://api.github.com/repos/tqdm/tqdm/statuses/fda5612f33a36ffd2b6e32ad5195a990a4628ae7","head":{"label":"chengs:weakset_keyerror","ref":"weakset_keyerror","sha":"fda5612f33a36ffd2b6e32ad5195a990a4628ae7","user":{"login":"chengs","id":824529,"node_id":"MDQ6VXNlcjgyNDUyOQ==","avatar_url":"https://avatars2.githubusercontent.com/u/824529?v=4","gravatar_id":"","url":"https://api.github.com/users/chengs","html_url":"https://github.com/chengs","followers_url":"https://api.github.com/users/chengs/followers","following_url":"https://api.github.com/users/chengs/following{/other_user}","gists_url":"https://api.github.com/users/chengs/gists{/gist_id}","starred_url":"https://api.github.com/users/chengs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chengs/subscriptions","organizations_url":"https://api.github.com/users/chengs/orgs","repos_url":"https://api.github.com/users/chengs/repos","events_url":"https://api.github.com/users/chengs/events{/privacy}","received_events_url":"https://api.github.com/users/chengs/received_events","type":"User","site_admin":false},"repo":{"id":106515734,"node_id":"MDEwOlJlcG9zaXRvcnkxMDY1MTU3MzQ=","name":"tqdm","full_name":"chengs/tqdm","owner":{"login":"chengs","id":824529,"node_id":"MDQ6VXNlcjgyNDUyOQ==","avatar_url":"https://avatars2.githubusercontent.com/u/824529?v=4","gravatar_id":"","url":"https://api.github.com/users/chengs","html_url":"https://github.com/chengs","followers_url":"https://api.github.com/users/chengs/followers","following_url":"https://api.github.com/users/chengs/following{/other_user}","gists_url":"https://api.github.com/users/chengs/gists{/gist_id}","starred_url":"https://api.github.com/users/chengs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chengs/subscriptions","organizations_url":"https://api.github.com/users/chengs/orgs","repos_url":"https://api.github.com/users/chengs/repos","events_url":"https://api.github.com/users/chengs/events{/privacy}","received_events_url":"https://api.github.com/users/chengs/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/chengs/tqdm","description":"A fast, extensible progress bar for Python and CLI","fork":true,"url":"https://api.github.com/repos/chengs/tqdm","forks_url":"https://api.github.com/repos/chengs/tqdm/forks","keys_url":"https://api.github.com/repos/chengs/tqdm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chengs/tqdm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chengs/tqdm/teams","hooks_url":"https://api.github.com/repos/chengs/tqdm/hooks","issue_events_url":"https://api.github.com/repos/chengs/tqdm/issues/events{/number}","events_url":"https://api.github.com/repos/chengs/tqdm/events","assignees_url":"https://api.github.com/repos/chengs/tqdm/assignees{/user}","branches_url":"https://api.github.com/repos/chengs/tqdm/branches{/branch}","tags_url":"https://api.github.com/repos/chengs/tqdm/tags","blobs_url":"https://api.github.com/repos/chengs/tqdm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chengs/tqdm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chengs/tqdm/git/refs{/sha}","trees_url":"https://api.github.com/repos/chengs/tqdm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chengs/tqdm/statuses/{sha}","languages_url":"https://api.github.com/repos/chengs/tqdm/languages","stargazers_url":"https://api.github.com/repos/chengs/tqdm/stargazers","contributors_url":"https://api.github.com/repos/chengs/tqdm/contributors","subscribers_url":"https://api.github.com/repos/chengs/tqdm/subscribers","subscription_url":"https://api.github.com/repos/chengs/tqdm/subscription","commits_url":"https://api.github.com/repos/chengs/tqdm/commits{/sha}","git_commits_url":"https://api.github.com/repos/chengs/tqdm/git/commits{/sha}","comments_url":"https://api.github.com/repos/chengs/tqdm/comments{/number}","issue_comment_url":"https://api.github.com/repos/chengs/tqdm/issues/comments{/number}","contents_url":"https://api.github.com/repos/chengs/tqdm/contents/{+path}","compare_url":"https://api.github.com/repos/chengs/tqdm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chengs/tqdm/merges","archive_url":"https://api.github.com/repos/chengs/tqdm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chengs/tqdm/downloads","issues_url":"https://api.github.com/repos/chengs/tqdm/issues{/number}","pulls_url":"https://api.github.com/repos/chengs/tqdm/pulls{/number}","milestones_url":"https://api.github.com/repos/chengs/tqdm/milestones{/number}","notifications_url":"https://api.github.com/repos/chengs/tqdm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chengs/tqdm/labels{/name}","releases_url":"https://api.github.com/repos/chengs/tqdm/releases{/id}","deployments_url":"https://api.github.com/repos/chengs/tqdm/deployments","created_at":"2017-10-11T06:43:38Z","updated_at":"2018-09-06T06:12:29Z","pushed_at":"2018-09-10T07:54:09Z","git_url":"git://github.com/chengs/tqdm.git","ssh_url":"git@github.com:chengs/tqdm.git","clone_url":"https://github.com/chengs/tqdm.git","svn_url":"https://github.com/chengs/tqdm","homepage":"https://pypi.python.org/pypi/tqdm","size":3511,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"tqdm:master","ref":"master","sha":"a2514e8ec0e5f71803cc392f9d696674e893ee01","user":{"login":"tqdm","id":12731565,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyNzMxNTY1","avatar_url":"https://avatars2.githubusercontent.com/u/12731565?v=4","gravatar_id":"","url":"https://api.github.com/users/tqdm","html_url":"https://github.com/tqdm","followers_url":"https://api.github.com/users/tqdm/followers","following_url":"https://api.github.com/users/tqdm/following{/other_user}","gists_url":"https://api.github.com/users/tqdm/gists{/gist_id}","starred_url":"https://api.github.com/users/tqdm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tqdm/subscriptions","organizations_url":"https://api.github.com/users/tqdm/orgs","repos_url":"https://api.github.com/users/tqdm/repos","events_url":"https://api.github.com/users/tqdm/events{/privacy}","received_events_url":"https://api.github.com/users/tqdm/received_events","type":"Organization","site_admin":false},"repo":{"id":36804486,"node_id":"MDEwOlJlcG9zaXRvcnkzNjgwNDQ4Ng==","name":"tqdm","full_name":"tqdm/tqdm","owner":{"login":"tqdm","id":12731565,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyNzMxNTY1","avatar_url":"https://avatars2.githubusercontent.com/u/12731565?v=4","gravatar_id":"","url":"https://api.github.com/users/tqdm","html_url":"https://github.com/tqdm","followers_url":"https://api.github.com/users/tqdm/followers","following_url":"https://api.github.com/users/tqdm/following{/other_user}","gists_url":"https://api.github.com/users/tqdm/gists{/gist_id}","starred_url":"https://api.github.com/users/tqdm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tqdm/subscriptions","organizations_url":"https://api.github.com/users/tqdm/orgs","repos_url":"https://api.github.com/users/tqdm/repos","events_url":"https://api.github.com/users/tqdm/events{/privacy}","received_events_url":"https://api.github.com/users/tqdm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tqdm/tqdm","description":"A fast, extensible progress bar for Python and CLI","fork":false,"url":"https://api.github.com/repos/tqdm/tqdm","forks_url":"https://api.github.com/repos/tqdm/tqdm/forks","keys_url":"https://api.github.com/repos/tqdm/tqdm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tqdm/tqdm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tqdm/tqdm/teams","hooks_url":"https://api.github.com/repos/tqdm/tqdm/hooks","issue_events_url":"https://api.github.com/repos/tqdm/tqdm/issues/events{/number}","events_url":"https://api.github.com/repos/tqdm/tqdm/events","assignees_url":"https://api.github.com/repos/tqdm/tqdm/assignees{/user}","branches_url":"https://api.github.com/repos/tqdm/tqdm/branches{/branch}","tags_url":"https://api.github.com/repos/tqdm/tqdm/tags","blobs_url":"https://api.github.com/repos/tqdm/tqdm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tqdm/tqdm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tqdm/tqdm/git/refs{/sha}","trees_url":"https://api.github.com/repos/tqdm/tqdm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tqdm/tqdm/statuses/{sha}","languages_url":"https://api.github.com/repos/tqdm/tqdm/languages","stargazers_url":"https://api.github.com/repos/tqdm/tqdm/stargazers","contributors_url":"https://api.github.com/repos/tqdm/tqdm/contributors","subscribers_url":"https://api.github.com/repos/tqdm/tqdm/subscribers","subscription_url":"https://api.github.com/repos/tqdm/tqdm/subscription","commits_url":"https://api.github.com/repos/tqdm/tqdm/commits{/sha}","git_commits_url":"https://api.github.com/repos/tqdm/tqdm/git/commits{/sha}","comments_url":"https://api.github.com/repos/tqdm/tqdm/comments{/number}","issue_comment_url":"https://api.github.com/repos/tqdm/tqdm/issues/comments{/number}","contents_url":"https://api.github.com/repos/tqdm/tqdm/contents/{+path}","compare_url":"https://api.github.com/repos/tqdm/tqdm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tqdm/tqdm/merges","archive_url":"https://api.github.com/repos/tqdm/tqdm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tqdm/tqdm/downloads","issues_url":"https://api.github.com/repos/tqdm/tqdm/issues{/number}","pulls_url":"https://api.github.com/repos/tqdm/tqdm/pulls{/number}","milestones_url":"https://api.github.com/repos/tqdm/tqdm/milestones{/number}","notifications_url":"https://api.github.com/repos/tqdm/tqdm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tqdm/tqdm/labels{/name}","releases_url":"https://api.github.com/repos/tqdm/tqdm/releases{/id}","deployments_url":"https://api.github.com/repos/tqdm/tqdm/deployments","created_at":"2015-06-03T13:13:14Z","updated_at":"2018-09-10T07:58:20Z","pushed_at":"2018-09-10T04:23:33Z","git_url":"git://github.com/tqdm/tqdm.git","ssh_url":"git@github.com:tqdm/tqdm.git","clone_url":"https://github.com/tqdm/tqdm.git","svn_url":"https://github.com/tqdm/tqdm","homepage":"https://pypi.python.org/pypi/tqdm","size":3415,"stargazers_count":7293,"watchers_count":7293,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":368,"mirror_url":null,"archived":false,"open_issues_count":141,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":368,"open_issues":141,"watchers":7293,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tqdm/tqdm/pulls/607"},"html":{"href":"https://github.com/tqdm/tqdm/pull/607"},"issue":{"href":"https://api.github.com/repos/tqdm/tqdm/issues/607"},"comments":{"href":"https://api.github.com/repos/tqdm/tqdm/issues/607/comments"},"review_comments":{"href":"https://api.github.com/repos/tqdm/tqdm/pulls/607/comments"},"review_comment":{"href":"https://api.github.com/repos/tqdm/tqdm/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tqdm/tqdm/pulls/607/commits"},"statuses":{"href":"https://api.github.com/repos/tqdm/tqdm/statuses/fda5612f33a36ffd2b6e32ad5195a990a4628ae7"}},"author_association":"COLLABORATOR","merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":true,"commits":1,"additions":6,"deletions":1,"changed_files":1}}
{"actor":{"display_login":"chengs"}}