Python Error Messages

jonathon jblake at stamp-coin.com
Thu Sep 9 04:52:22 EDT 1999


	Why are PythonError messages so annoying?

	I've been trying to debug a script for the last four days,
	to no avail.  With two of the four databases I run it on,
	the script does just what it is supposed to.  On the other
	two databases, it doesn't.

	The current exasperating error message:

	Traceback (innermost last)
	  File "mass.py", line 21102 in ?
            print changed_field, " is record_list[28] "
          File "mass.py", line 20610 in print_web_page
            table_prefix = "<tr><td> "
	  TypeError:  illegal argument type for built in operation.

	**********************************************************

	Line 21100 et al are:

       if temp_field == changed_field :
           good_datafile.write( temp_line + '\n' )
           test_datafile.write( test_line + '\n' )  #  line 21102
           check_point = print_country(record_list, temp_line)
           check_point = create_country_table( record_list, country_line )
           check_point = print_web_page ( record_list )
       else:
           error_file.write( temp_line + '\n' )

	***

	Line 20607 et al are:

   make_table = '</p><p> <TABLE align = "center" border = "5" cellpadding = "5" cellspacing = "5" frame = "box" width = "95%" bgcolor = "#333333" rules = "all"  ><caption>'
   caption = '"Stamp Data" </caption>'
   table_prefix = "<tr><td> "
   table_break = " </td><td> "
   table_suffix = "</td></tr> "  # line 20610
   title_name = (title_prefix + country_name + bang_two + scott_data + bang_two + michel_data )
   add_keywords = ( pre_keywords + country_name + country_section_name + scott_data + michel_data + y_t_data + s_g_data + minkus_data + end_of_line )
   file_description = ( pre_describe + description_prefix + country_name + bang_two + country_section_name + bang_two + scott_data + bang_two + michel_data + end_of_line )

	***************

	Now what is infuriating, is that the script has run over this
	particular code sequence at least 4000 times, before giving me
	this error.  

	For those that want to look at the script in its entirety, it
	is at http://www.stamp-coin.com/python/python_errors/index.html.
	[  22000 lines for the script.  The approxomate file size of
	the data files is lsited there.  ] 

	******************************

	I don't have the error message for the other frustration, but
	the python script was truncating a record, for no apparant 
	reason.  Worse still, none of the previous records had been
	truncated.  

	One of them is a simple assignment, the other is a simple
	writeline to file.

	Questions:

	What would trigger these error messages, when there were no
	apparant problems earlier?

	How do I do exception handling that maintains something sane,
	when the script obviously isn't?

	One thing i have noticed, is that the print statements I put
	in, to try to follow what was happening, tend to indicate
	that the actual problem is more than a couple of lines away
	from the line(s) that are quoted on the screen.

	xan

	jonathon





More information about the Python-list mailing list