@@ -83,13 +83,15 @@ def showsyntaxerror(self, filename=None):
8383 if filename and type is SyntaxError :
8484 # Work hard to stuff the correct filename in the exception
8585 try :
86- msg , (dummy_filename , lineno , offset , line ) = value
86+ msg , (dummy_filename , lineno , offset , line ) = value . args
8787 except :
8888 # Not the format we expect; leave it alone
8989 pass
9090 else :
9191 # Stuff in the right filename and right lineno
92- value = SyntaxError (msg , (filename , lineno - 1 , offset , line ))
92+ if not py3 :
93+ lineno -= 1
94+ value = SyntaxError (msg , (filename , lineno , offset , line ))
9395 sys .last_value = value
9496 list = traceback .format_exception_only (type , value )
9597 self .writetb (list )
@@ -106,7 +108,10 @@ def showtraceback(self):
106108 tblist = traceback .extract_tb (tb )
107109 del tblist [:1 ]
108110 # Set the right lineno (encoding header adds an extra line)
109- tblist [0 ] = (tblist [0 ][0 ], 1 ) + tblist [0 ][2 :]
111+ lineno = tblist [0 ][1 ]
112+ if not py3 :
113+ lineno -= 1
114+ tblist [0 ] = (tblist [0 ][0 ], lineno ) + tblist [0 ][2 :]
110115
111116 l = traceback .format_list (tblist )
112117 if l :
0 commit comments