bpo-37685: Fixed __eq__, __lt__ etc implementations in some classes. (GH-14952)

They now return NotImplemented for unsupported type of the other operand.
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index 96d85e2..72dc7af 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -7,7 +7,7 @@
 import unittest
 import re
 from test import support
-from test.support import TESTFN, Error, captured_output, unlink, cpython_only
+from test.support import TESTFN, Error, captured_output, unlink, cpython_only, ALWAYS_EQ
 from test.support.script_helper import assert_python_ok
 import textwrap
 
@@ -887,6 +887,8 @@
         # operator fallbacks to FrameSummary.__eq__.
         self.assertEqual(tuple(f), f)
         self.assertIsNone(f.locals)
+        self.assertNotEqual(f, object())
+        self.assertEqual(f, ALWAYS_EQ)
 
     def test_lazy_lines(self):
         linecache.clearcache()
@@ -1083,6 +1085,18 @@
         self.assertEqual(exc_info[0], exc.exc_type)
         self.assertEqual(str(exc_info[1]), str(exc))
 
+    def test_comparison(self):
+        try:
+            1/0
+        except Exception:
+            exc_info = sys.exc_info()
+            exc = traceback.TracebackException(*exc_info)
+            exc2 = traceback.TracebackException(*exc_info)
+        self.assertIsNot(exc, exc2)
+        self.assertEqual(exc, exc2)
+        self.assertNotEqual(exc, object())
+        self.assertEqual(exc, ALWAYS_EQ)
+
     def test_unhashable(self):
         class UnhashableException(Exception):
             def __eq__(self, other):