TypeError: bad argument type for built-in operation
Reported by seb | May 18th, 2009 @ 12:32 PM
I added this test to test/test-object.py:
@t.cx() def test_array_access(cx):
cx.add_global("test", [1, 2, 3])
t.eq(cx.execute("test[0]"), 1)
It fails with this error:
======================================================================
ERROR: test-object.test_array_access
Traceback (most recent call last):
File
"/usr/lib/python2.5/site-packages/nose-0.10.4-py2.5.egg/nose/case.py",
line 182, in runTest
self.test(*self.arg)
File "/usr/lib/python2.5/site-packages/nose-0.10.4-py2.5.egg/nose/util.py", line 596, in newfunc
return func(*arg, **kw)
File "/home/seb/tmp/python-spidermonkey/tests/t.py", line 12, in run
func(*self.args())
File "/home/seb/tmp/python-spidermonkey/tests/test-object.py", line 83, in test_array_access
t.eq(cx.execute("test[0]"), 1)
TypeError: bad argument type for built-in operation
Comments and changes to this ticket
-
Paul J. Davis May 18th, 2009 @ 01:05 PM
Most odd. Nothing comes to mind off the top of my head. I'll take a
closer look when I get home tonight.Thanks for the report.
-
seb May 18th, 2009 @ 04:51 PM
I fixed the bug.
git://github.com/spahl/python-spidermonkey.git
There is still a problem left, it doesn't work in this case:
test = {1.1 : 0} test[1.1]
ps: sorry for the formatting in the first bug report:-)
-
Paul J. Davis May 18th, 2009 @ 04:55 PM
seb,
Now that you tracked that down I realize that the error is that I was
being a moron and only allowing string values as keys there. When I
get home I'll update to only do the utf8 dance if it's a string
otherwise just take the key as is.Thanks for the follow up on this.
Paul
-
Paul J. Davis May 18th, 2009 @ 07:32 PM
- State changed from new to resolved
(from [e75f991342e41d62647aa5f557eaff784598ff4b]) Fix integer property lookups.
>>> rt = spidermonkey.Runtime() >>> cx = rt.new_context() >>> cx.add_global("bang", [2, "got me!"]) >>> assert cx.execute("bang[1];") == "got me!"
Thanks to spahl for the report and fix.
[#16 state:resolved] http://github.com/davisp/python-spidermonkey/commit/e75f991342e41d6...
-
Paul J. Davis May 18th, 2009 @ 07:33 PM
I should've mentioned in the commit, but property access by anything other than an integer or string won't work as Spidermonkey will convert anything else to a string before it reaches Python.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
Python/JavaScript bridge module, making use of Mozilla's spidermonkey JavaScript implementation. Allows implementation of JavaScript classes, objects and functions in Python, and evaluation and calling of JavaScript scripts and functions respectively. Borrows heavily from Claes Jacobssen's Javascript Perl module, in turn based on Mozilla's 'PerlConnect' Perl binding.
People watching this ticket
Referenced by
- 1 Enumerate Python objects in JavaScript [#16 state:resolved] http://github.com/davisp/python-spi...
- 16 TypeError: bad argument type for built-in operation [#16 state:resolved] http://github.com/davisp/python-spi...