Python Exception error

473
2
Jump to solution
04-16-2013 05:03 PM
JohnMcGlynn
Occasional Contributor
I am trying to repair a Python script that has thrown the error:

<type 'exceptions.TypeError'>: exceptions must be classes, instances, or strings (deprecated), not unicode

The part of the code it is referring to is

for upload in uploads:         try:             process(upload,method,doforcenow)         except Arcgisscripting.ExecuteError:      #<< Line where error is reported             msgs = gp.GetMessage(0)             msgs += gp.GetMessages(2)             gp.AddError(msgs)             logMsg("\tError: "+ msgs)             errorOccurred(True)             pass         except:             # Get the traceback object             tb = sys.exc_info()[2]             tbinfo = traceback.format_tb(tb)[0]             pymsg = tbinfo + "\n" + str(sys.exc_type)+ ": " + str(sys.exc_value)             gp.AddError(pymsg)             logMsg("\tError: " +pymsg)             pass


The Python version is 2.5 and it is using ESRI v9.3.1 SP1.

I found a web page that had the Arcgisscripting.ExecuteError part of the exception single quoted.
That didn't work. It simply reported that the exception couldn't be handled.

Can anyone tell me how to fix this error?

Thanks
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JohnMcGlynn
Occasional Contributor
Yes! That was it. The arcgisscripting shouldn't be capitalised.

Thanks

View solution in original post

0 Kudos
2 Replies
DanPatterson_Retired
MVP Emeritus
9.3 was a while ago, but is arcgisscripting capitalized?
0 Kudos
JohnMcGlynn
Occasional Contributor
Yes! That was it. The arcgisscripting shouldn't be capitalised.

Thanks
0 Kudos