Patch #1515343: Fix printing of deprecated string exceptions with a
value in the traceback module.
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index 1b59f98..4ecd2cd 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -31,8 +31,9 @@
         err = self.get_exception_format(self.syntax_error_with_caret,
                                         SyntaxError)
         self.assert_(len(err) == 4)
-        self.assert_("^" in err[2]) # third line has caret
         self.assert_(err[1].strip() == "return x!")
+        self.assert_("^" in err[2]) # third line has caret
+        self.assert_(err[1].find("!") == err[2].find("^")) # in the right place
 
     def test_nocaret(self):
         if is_jython:
@@ -47,8 +48,9 @@
         err = self.get_exception_format(self.syntax_error_bad_indentation,
                                         IndentationError)
         self.assert_(len(err) == 4)
-        self.assert_("^" in err[2])
         self.assert_(err[1].strip() == "print 2")
+        self.assert_("^" in err[2])
+        self.assert_(err[1].find("2") == err[2].find("^"))
 
     def test_bug737473(self):
         import sys, os, tempfile, time
@@ -109,6 +111,36 @@
         lst = traceback.format_exception_only(e.__class__, e)
         self.assertEqual(lst, ['KeyboardInterrupt\n'])
 
+    # String exceptions are deprecated, but legal.  The quirky form with
+    # separate "type" and "value" tends to break things, because 
+    #     not isinstance(value, type)
+    # and a string cannot be the first argument to issubclass.
+    #
+    # Note that sys.last_type and sys.last_value do not get set if an
+    # exception is caught, so we sort of cheat and just emulate them.
+    #
+    # test_string_exception1 is equivalent to
+    #
+    # >>> raise "String Exception"
+    #
+    # test_string_exception2 is equivalent to
+    #
+    # >>> raise "String Exception", "String Value"
+    #
+    def test_string_exception1(self):
+        str_type = "String Exception"
+        err = traceback.format_exception_only(str_type, None)
+        self.assert_(len(err) == 1)
+        self.assert_(err[0] == str_type + '\n')
+
+    def test_string_exception2(self):
+        str_type = "String Exception"
+        str_value = "String Value"
+        err = traceback.format_exception_only(str_type, str_value)
+        self.assert_(len(err) == 1)
+        self.assert_(err[0] == str_type + ': ' + str_value + '\n')
+        
+
 def test_main():
     run_unittest(TracebackCases)