Skip to content
  • Mathieu Bridon's avatar
    python: Fix inequality comparisons · 15ac05fd
    Mathieu Bridon authored and Dylan Baker's avatar Dylan Baker committed
    
    
    On Python 3, executing `foo != bar` will first try to call
    foo.__ne__(bar), and fallback on the opposite result of foo.__eq__(bar).
    
    Python 2 does not do that.
    
    As a result, those __eq__ methods were never called, when we were
    testing for inequality.
    
    Expliclty adding the __ne__ methods fixes this issue, in a way that is
    compatible with both Python 2 and 3.
    
    However, this means the __eq__ methods are now called when testing for
    `foo != None`, so they need to be guarded correctly.
    
    Signed-off-by: default avatarMathieu Bridon <bochecha@daitauha.fr>
    Reviewed-by: default avatarDylan Baker <dylan@pnwbakers.com>
    15ac05fd