Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

TypeError: bad argument type for built-in operation

#16

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


Reported by seb · May 18th, 2009 @ 12:32 PM

State: resolved
Milestone: none
Assigned to: Paul J. Davis Paul J. Davis

Activity

  1. Paul J. Davis
    Paul J. Davis

    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.

    May 18th, 2009 @ 01:05 PM

  2. seb
    seb

    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:-)

    May 18th, 2009 @ 04:51 PM

  3. Paul J. Davis
    Paul J. Davis

    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

    May 18th, 2009 @ 04:55 PM

  4. Paul J. Davis
    Paul J. Davis
    • 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 TypeError: bad argument type for built-in operation state:resolved] http://github.com/davisp/python-spidermonkey/commit/e75f991342e41d6...

    May 18th, 2009 @ 07:32 PM

  5. Paul J. Davis
    Paul J. Davis

    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.

    May 18th, 2009 @ 07:33 PM

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.