--- a/src/freemarker/ext/jython/JythonHashModel.java
+++ b/src/freemarker/ext/jython/JythonHashModel.java
@@ -137,7 +137,7 @@
         {
             throw new TemplateModelException(e);
         }
-        throw new TemplateModelException("'?keys' is not supported as there is no 'keys' nor 'keySet' attribute on an instance of " + object.__class__.__name__);
+        throw new TemplateModelException("'?keys' is not supported as there is no 'keys' nor 'keySet' attribute on an instance of " + object.getType().getFullName());
     }
 
     /**
@@ -157,6 +157,6 @@
         {
             throw new TemplateModelException(e);
         }
-        throw new TemplateModelException("'?values' is not supported as there is no 'values' attribute on an instance of " + object.__class__.__name__);
+        throw new TemplateModelException("'?values' is not supported as there is no 'values' attribute on an instance of " + object.getType().getFullName());
     }
 }
