changeset 73:efa0cfe6fc03

Resolved two TODOs.
author Atul Varma <varmaa@toolness.com>
date Mon, 27 Jul 2009 22:00:03 -0700
parents cd545c03eeef
children e06376295170
files context.c test_pymonkey.py
diffstat 2 files changed, 14 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/context.c	Mon Jul 27 21:53:43 2009 -0700
+++ b/context.c	Mon Jul 27 22:00:03 2009 -0700
@@ -125,9 +125,7 @@
   PyObject *pyObject;
 
   if (!PYM_JS_getPrivatePyObject(self->cx, object->obj, &pyObject)) {
-    // TODO: Get the actual JS exception. Any exception that exists
-    // here will probably still be pending on the JS context.
-    PyErr_SetString(PYM_error, "Getting private failed.");
+    PYM_jsExceptionToPython(self);
     return NULL;
   }
 
@@ -184,9 +182,7 @@
   Py_END_ALLOW_THREADS;
 
   if (!result) {
-    // TODO: Get the actual JS exception. Any exception that exists
-    // here will probably still be pending on the JS context.
-    PyErr_SetString(PYM_error, "Getting property failed.");
+    PYM_jsExceptionToPython(self);
     return NULL;
   }
 
--- a/test_pymonkey.py	Mon Jul 27 21:53:43 2009 -0700
+++ b/test_pymonkey.py	Mon Jul 27 22:00:03 2009 -0700
@@ -254,6 +254,18 @@
         self.assertTrue(cx.get_property(obj, u"foo") is
                         cx.get_property(obj, u"foo"))
 
+    def testObjectGetattrThrowsException(self):
+        cx = pymonkey.Runtime().new_context()
+        obj = cx.new_object()
+        cx.init_standard_classes(obj)
+        result = cx.evaluate_script(obj, '({get foo() { throw "blah"; }})',
+                                    '<string>', 1)
+        self.assertRaises(pymonkey.error,
+                          cx.get_property,
+                          result,
+                          u"foo")
+        self.assertEqual(self.last_exception.message, u"blah")
+
     def testObjectGetattrWorks(self):
         cx = pymonkey.Runtime().new_context()
         obj = cx.new_object()