classification
Title: empty set difference does not check types of values
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.9, Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: Anthony Sottile, rhettinger
Priority: high Keywords: patch

Created on 2019-06-10 22:01 by Anthony Sottile, last changed 2019-06-11 09:01 by rhettinger. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 13965 merged rhettinger, 2019-06-11 06:27
PR 13967 merged miss-islington, 2019-06-11 08:24
PR 13968 merged rhettinger, 2019-06-11 08:40
Messages (5)
msg345147 - (view) Author: Anthony Sottile (Anthony Sottile) * Date: 2019-06-10 22:01
This is a regression from python2.x behaviour:

$ python2
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15) 
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> x = set()
>>> x.difference(123)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'int' object is not iterable


$ python3.8
Python 3.8.0b1 (default, Jun  6 2019, 03:44:52) 
[GCC 7.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> x = set()
>>> x.difference(123)
set()

The regression appears to be introduced in this patch: 4103e4dfbce

https://github.com/python/cpython/commit/4103e4dfbce
msg345181 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-06-11 05:25
Nice catch.  Thanks.
msg345199 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-06-11 08:16
New changeset 1f11cf9521114447b3e32e2ac88f075ffaa37555 by Raymond Hettinger in branch 'master':
bpo-37219: Remove erroneous optimization for differencing an empty set (GH-13965)
https://github.com/python/cpython/commit/1f11cf9521114447b3e32e2ac88f075ffaa37555
msg345200 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-06-11 08:41
New changeset 583ff84351e528976aa93d383e5a81aee9f3bac3 by Raymond Hettinger (Miss Islington (bot)) in branch '3.8':
bpo-37219: Remove erroneous optimization for differencing an empty set (GH-13965) (GH-13967)
https://github.com/python/cpython/commit/583ff84351e528976aa93d383e5a81aee9f3bac3
msg345205 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-06-11 09:01
New changeset 1b615b2f035d207941e44259a92ed0bdcc56ac45 by Raymond Hettinger in branch '3.7':
[3.7] bpo-37219: Remove erroneous optimization for differencing an empty set (GH-13965) (GH-13968)
https://github.com/python/cpython/commit/1b615b2f035d207941e44259a92ed0bdcc56ac45
History
Date User Action Args
2019-06-11 09:01:44rhettingersetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-06-11 09:01:27rhettingersetmessages: + msg345205
2019-06-11 08:41:30rhettingersetmessages: + msg345200
2019-06-11 08:40:43rhettingersetpull_requests: + pull_request13835
2019-06-11 08:24:08miss-islingtonsetpull_requests: + pull_request13834
2019-06-11 08:16:06rhettingersetmessages: + msg345199
2019-06-11 06:27:59rhettingersetkeywords: + patch
stage: patch review
pull_requests: + pull_request13832
2019-06-11 05:25:04rhettingersetpriority: normal -> high
assignee: rhettinger
messages: + msg345181
2019-06-10 22:01:36Anthony Sottilecreate