On 12/22/2014 06:10 PM, ronald.kevin.bur...@gmail.com wrote:
I am getting an exception that the traceback looks like:

------------------------------------------------------------
Traceback (most recent call last):
   File "C:\Projects\QA\robot_20141103\resources\assessment_utilities.py", line 
29, in create_new_project
     program = customer.add(program_code)
   File "C:\Projects\QA\robot_20141103\resources\assessment_customer.py", line 
589, in add
     program = ProgramMaker.Code2Program(program_code, self)
   File "C:\Projects\QA\robot_20141103\resources\programmaker.py", line 25, in 
Code2Program
     'ASSESS_PPL' : PPL(customer)
   File "C:\Projects\QA\robot_20141103\resources\ppl.py", line 20, in __init__
     MeasureMaker.Code2Measure('Furnace Whistle', self)
TypeError: unhashable type: 'list'
------------------------------------------------------------    

My problem is that I am not sure what the problem is. I can check the type of 
'self' which is an object and the string 'Furnace Whistle' is obviously not a 
list. The static function 'MeasureMaker.Code2Measure' is a simple factory:

class MeasureMaker:

     def Code2Measure(measure_code, core):
         try:
             return {
...
                 'Furnace Whistle': FurnaceWhistle(core)
             }[measure_code]
         except KeyError as error:
             return None
     Code2Measure = staticmethod(Code2Measure)

What is the 'list' that is in the exception? Or how do I find out?



I don't see enough pieces to tell the problem at all. The two lowest levels of stack trace are on line 20 and 25, and you don't include either of those in your fragments. Further, since many of your statements are multi-statement lines, the problem isn't necessarily showing in the stack trace, which only shows one line of the offending statement.

Finally, I suspect PPL is some form of alias, which you don't show either. And the stack trace shows four different source files. Probably only the last two matter, but it'd be very useful to see the class/function definitions involved in their entirety, plus any "from xxx import yyy" type aliases that may be relevant.

Are you perhaps using Python 2.x ? If so, you want to inherit from object. I doubt that's your problem, but it's a missing clue. Always state your Python version when describing a new problem.

BTW, using @staticmethod decorator is usually clearer than the way you have it here. But that's no bug either.

--
DaveA

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to