Merge
This commit is contained in:
parent
33df0c3fb6
commit
4c483ad52b
|
@ -389,6 +389,21 @@ class TestSet(TestJointOps, unittest.TestCase):
|
||||||
t = {1,2,3}
|
t = {1,2,3}
|
||||||
self.assertEqual(s, t)
|
self.assertEqual(s, t)
|
||||||
|
|
||||||
|
def test_set_literal_insertion_order(self):
|
||||||
|
# SF Issue #26020 -- Expect left to right insertion
|
||||||
|
s = {1, 1.0, True}
|
||||||
|
self.assertEqual(len(s), 1)
|
||||||
|
stored_value = s.pop()
|
||||||
|
self.assertEqual(type(stored_value), int)
|
||||||
|
|
||||||
|
def test_set_literal_evaluation_order(self):
|
||||||
|
# Expect left to right expression evaluation
|
||||||
|
events = []
|
||||||
|
def record(obj):
|
||||||
|
events.append(obj)
|
||||||
|
s = {record(1), record(2), record(3)}
|
||||||
|
self.assertEqual(events, [1, 2, 3])
|
||||||
|
|
||||||
def test_hash(self):
|
def test_hash(self):
|
||||||
self.assertRaises(TypeError, hash, self.s)
|
self.assertRaises(TypeError, hash, self.s)
|
||||||
|
|
||||||
|
|
|
@ -2619,14 +2619,16 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
|
||||||
TARGET(BUILD_SET) {
|
TARGET(BUILD_SET) {
|
||||||
PyObject *set = PySet_New(NULL);
|
PyObject *set = PySet_New(NULL);
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
int i;
|
||||||
if (set == NULL)
|
if (set == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
while (--oparg >= 0) {
|
for (i = oparg; i > 0; i--) {
|
||||||
PyObject *item = POP();
|
PyObject *item = PEEK(i);
|
||||||
if (err == 0)
|
if (err == 0)
|
||||||
err = PySet_Add(set, item);
|
err = PySet_Add(set, item);
|
||||||
Py_DECREF(item);
|
Py_DECREF(item);
|
||||||
}
|
}
|
||||||
|
STACKADJ(-oparg);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
Py_DECREF(set);
|
Py_DECREF(set);
|
||||||
goto error;
|
goto error;
|
||||||
|
|
Loading…
Reference in New Issue