The TypeError: unhashable type at line 212 of copy.py is the
key.  You are probably trying to use a non-hashable type
as a key in a dictionary.  Wrap the operation at line 212
with something like the following to find out who the
culprit is:
 
>>> d = {}
>>> try:
...    {d:1}       # this would be your line 212
... except TypeError:
...    try:
...       hash(d)
...    except TypeError:
...       print "unable to hash object %s" % d
...
unable to hash object {}
 
As a hack, you may be able to hash the repr of the object:
 
>>> d = {}
>>> try:
...    {repr(d):1}
... except TypeError:
...    try:
...       hash(d)
...    except TypeError:
...       print "unable to hash object %s" % d
...
{'{}': 1}
But I'd avoid that if you can.
 
-Clark
 

From: jython-users-admin@lists.sourceforge.net on behalf of Steven Yi
Sent: Sat 7/9/2005 2:23 PM
To: jython-users@lists.sourceforge.net
Subject: [Jython-users] Intermiitent Errors in Deepcopy

Hi All,

I've been getting a strange intermittent error with Jython in my
program blue.  blue is a music program, and within it I have objects
which allow scripting using Jython.  Sometimes, some of my scripts
give errors like this:

Traceback (innermost last):
  File "<string>", line 4, in ?
  File "/home/steven/workspace/blue/lib/pythonLib/orchestra/PerformerGroup.py",
line 47, in performAleatorically
  File "/home/steven/workspace/blue/lib/pythonLib/orchestra/Performer.py",
line 66, in performAleatorically
  File "/home/steven/workspace/blue/lib/pythonLib/copy.py", line 163,
in deepcopy
  File "/home/steven/workspace/blue/lib/pythonLib/copy.py", line 254,
in _deepcopy_inst
  File "/home/steven/workspace/blue/lib/pythonLib/copy.py", line 163,
in deepcopy
  File "/home/steven/workspace/blue/lib/pythonLib/copy.py", line 212,
in _deepcopy_dict
  File "/home/steven/workspace/blue/lib/pythonLib/copy.py", line 163,
in deepcopy
  File "/home/steven/workspace/blue/lib/pythonLib/copy.py", line 185,
in _deepcopy_list
  File "/home/steven/workspace/blue/lib/pythonLib/copy.py", line 163,
in deepcopy
  File "/home/steven/workspace/blue/lib/pythonLib/copy.py", line 254,
in _deepcopy_inst
  File "/home/steven/workspace/blue/lib/pythonLib/copy.py", line 163,
in deepcopy
  File "/home/steven/workspace/blue/lib/pythonLib/copy.py", line 212,
in _deepcopy_dict
TypeError: unhashable type

but the errors are not consistent.  I will set the program to render
the project in a loop mode, and maybe after the first time, maybe the
fifth time, maybe longer, this error is likely to happen, but I can
not predict when it will happen.  I have been looking around for
information on this but have not yet found an answer, and I have not
been able to easily debug this as I haven't found how to get a stack
trace that will go into the Jython java classes calls, only the error
message above.

If anyone has seen this kind of error where it works sometimes and can
direct me on how I could fix this issue, I would very much appreciate
it.  I can also send copies of the scripts I use if that could help
diagnose this.

I found this error to occur on both Windows and Linux, both using Java
1.5.0 JDK's.

Any help would be greatly appreciated!
Thanks,
steven


-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
Jython-users mailing list
Jython-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users