[Python-checkins] python/dist/src/Lib sets.py,1.18,1.19

rhettinger@users.sourceforge.net rhettinger@users.sourceforge.net
Fri, 23 Aug 2002 23:19:05 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv29560

Modified Files:
	sets.py 
Log Message:
At Tim Peter's suggestion, propagated GvR's binary operator changes to 
the inplace operators.  The strategy is to have the operator overloading
code do the work and then to define equivalent method calls which rely on
the operators.  The changes facilitate proper application of TypeError 
and NonImplementedErrors.

Added corresponding tests to the test suite to make sure both the operator
and method call versions get exercised.

Add missing tests for difference_update().



Index: sets.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sets.py,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** sets.py	24 Aug 2002 04:47:42 -0000	1.18
--- sets.py	24 Aug 2002 06:19:02 -0000	1.19
***************
*** 364,368 ****
      # In-place union, intersection, differences
  
!     def union_update(self, other):
          """Update a set with the union of itself and another."""
          self._binary_sanity_check(other)
--- 364,368 ----
      # In-place union, intersection, differences
  
!     def __ior__(self, other):
          """Update a set with the union of itself and another."""
          self._binary_sanity_check(other)
***************
*** 370,376 ****
          return self
  
!     __ior__ = union_update
  
!     def intersection_update(self, other):
          """Update a set with the intersection of itself and another."""
          self._binary_sanity_check(other)
--- 370,378 ----
          return self
  
!     def union_update(self, other):
!         """Update a set with the union of itself and another."""
!         self |= other
  
!     def __iand__(self, other):
          """Update a set with the intersection of itself and another."""
          self._binary_sanity_check(other)
***************
*** 380,386 ****
          return self
  
!     __iand__ = intersection_update
  
!     def symmetric_difference_update(self, other):
          """Update a set with the symmetric difference of itself and another."""
          self._binary_sanity_check(other)
--- 382,390 ----
          return self
  
!     def intersection_update(self, other):
!         """Update a set with the intersection of itself and another."""
!         self &= other
  
!     def __ixor__(self, other):
          """Update a set with the symmetric difference of itself and another."""
          self._binary_sanity_check(other)
***************
*** 394,400 ****
          return self
  
!     __ixor__ = symmetric_difference_update
  
!     def difference_update(self, other):
          """Remove all elements of another set from this set."""
          self._binary_sanity_check(other)
--- 398,406 ----
          return self
  
!     def symmetric_difference_update(self, other):
!         """Update a set with the symmetric difference of itself and another."""
!         self ^= other
  
!     def __isub__(self, other):
          """Remove all elements of another set from this set."""
          self._binary_sanity_check(other)
***************
*** 405,409 ****
          return self
  
!     __isub__ = difference_update
  
      # Python dict-like mass mutations: update, clear
--- 411,417 ----
          return self
  
!     def difference_update(self, other):
!         """Remove all elements of another set from this set."""
!         self -= other
  
      # Python dict-like mass mutations: update, clear