@@ -1620,32 +1620,38 @@ def __or__(self, other):
16201620 if other_value is NotImplemented :
16211621 return NotImplemented
16221622
1623- for flag in self , other :
1624- if self ._get_value (flag ) is None :
1625- raise TypeError (f"'{ flag } ' cannot be combined with other flags with |" )
16261623 value = self ._value_
1624+ # _get_value(self) is self._value_ and _get_value(other) is
1625+ # other_value, so only walk the operands (to raise on the offending
1626+ # flag) when one of those values is actually None.
1627+ if value is None or other_value is None :
1628+ for flag in self , other :
1629+ if self ._get_value (flag ) is None :
1630+ raise TypeError (f"'{ flag } ' cannot be combined with other flags with |" )
16271631 return self .__class__ (value | other_value )
16281632
16291633 def __and__ (self , other ):
16301634 other_value = self ._get_value (other )
16311635 if other_value is NotImplemented :
16321636 return NotImplemented
16331637
1634- for flag in self , other :
1635- if self ._get_value (flag ) is None :
1636- raise TypeError (f"'{ flag } ' cannot be combined with other flags with &" )
16371638 value = self ._value_
1639+ if value is None or other_value is None :
1640+ for flag in self , other :
1641+ if self ._get_value (flag ) is None :
1642+ raise TypeError (f"'{ flag } ' cannot be combined with other flags with &" )
16381643 return self .__class__ (value & other_value )
16391644
16401645 def __xor__ (self , other ):
16411646 other_value = self ._get_value (other )
16421647 if other_value is NotImplemented :
16431648 return NotImplemented
16441649
1645- for flag in self , other :
1646- if self ._get_value (flag ) is None :
1647- raise TypeError (f"'{ flag } ' cannot be combined with other flags with ^" )
16481650 value = self ._value_
1651+ if value is None or other_value is None :
1652+ for flag in self , other :
1653+ if self ._get_value (flag ) is None :
1654+ raise TypeError (f"'{ flag } ' cannot be combined with other flags with ^" )
16491655 return self .__class__ (value ^ other_value )
16501656
16511657 def __invert__ (self ):
0 commit comments