mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	bpo-37219: Remove erroneous optimization for differencing an empty set (GH-13965)
This commit is contained in:
		
							parent
							
								
									408a2ef1ac
								
							
						
					
					
						commit
						1f11cf9521
					
				
					 3 changed files with 7 additions and 8 deletions
				
			
		| 
						 | 
				
			
			@ -895,6 +895,12 @@ def test_pickling(self):
 | 
			
		|||
            self.assertEqual(self.set, copy,
 | 
			
		||||
                             "%s != %s" % (self.set, copy))
 | 
			
		||||
 | 
			
		||||
    def test_issue_37219(self):
 | 
			
		||||
        with self.assertRaises(TypeError):
 | 
			
		||||
            set().difference(123)
 | 
			
		||||
        with self.assertRaises(TypeError):
 | 
			
		||||
            set().difference_update(123)
 | 
			
		||||
 | 
			
		||||
#------------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
class TestBasicOpsEmpty(TestBasicOps, unittest.TestCase):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
Remove errorneous optimization for empty set differences.
 | 
			
		||||
| 
						 | 
				
			
			@ -1456,10 +1456,6 @@ PyDoc_STRVAR(isdisjoint_doc,
 | 
			
		|||
static int
 | 
			
		||||
set_difference_update_internal(PySetObject *so, PyObject *other)
 | 
			
		||||
{
 | 
			
		||||
    if (PySet_GET_SIZE(so) == 0) {
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if ((PyObject *)so == other)
 | 
			
		||||
        return set_clear_internal(so);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1534,10 +1530,6 @@ set_difference(PySetObject *so, PyObject *other)
 | 
			
		|||
    Py_ssize_t pos = 0, other_size;
 | 
			
		||||
    int rv;
 | 
			
		||||
 | 
			
		||||
    if (PySet_GET_SIZE(so) == 0) {
 | 
			
		||||
        return set_copy(so, NULL);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (PyAnySet_Check(other)) {
 | 
			
		||||
        other_size = PySet_GET_SIZE(other);
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue