Closed Bug 419765 Opened 17 years ago Closed 17 years ago

PyDOM script error, Python cannot handle dom events

Categories

(Core :: DOM: Core & HTML, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9beta4

People

(Reporter: twhitema, Assigned: twhitema)

References

Details

Attachments

(1 file)

User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.12) Gecko/20080207 Ubuntu/7.10 (gutsy) Firefox/2.0.0.12 Build Identifier: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9b4pre) When running "chrome://pyxultest/content/pyxultest.xul" window, any python event handler will complain with the following error message (i.e. click on the "click for python" button): WARNING:xpcom:Python DOM script error <type 'exceptions.TypeError'>: CompileEventHandler() takes exactly 7 arguments (6 given) Reproducible: Always Steps to Reproduce: 1. 2. 3.
This occurred after recent changes made by Boris Zbarsky to enable JS 1.7 version in XBL -> bug 389322 (so CC'ing him as well). The quick workaround I'm using is to change the version argument in CompileEventHandler to be optional through "version=None". I'm not sure that is the correct fix.
Oh yeah, I still get some nasty looking assertion (debug build) after using my above workaround: ###!!! ASSERTION: JSEventListener has wrong script context?: 'stack && NS_SUCCEEDED(stack->Peek(&cx)) && cx && GetScriptContextFromJSContext(cx) == mContext', file /home/toddw/src/mozilla/src/trunk/mozilla/dom/src/events/nsJSEventListener.cpp, line 244
Did I miss a CompileEventHandler() caller somewhere? Which one?
I should note that I did fix all the ones lxr shows... Did some sort of python glue code need to be regenerated after changing PyContext?
Blocks: 389322
Ah, you are right, there is some specific python glue used to make this work. In the "CompileEventHandler()" method in the file "nsPyContext.cpp", PyObject_CallMethod() uses the third argument to specify the number and type of the parameters that the python function will accept "sNNsi". This needs to be updated to include the new additional argument for the version number, i.e. "sNNsii". My moz build has gone awol at present, so I'll create a patch for this once I can generate a new build and verify the fix.
This patch includes adds the necessary glue for the additional version (integer) argument. This allows Python to correctly handle the dom events again.
Attachment #306021 - Flags: review?(mhammond)
Note that I am still receiving the following assertion error in my debug build after this patch is applied for every dom event Python is handling: ###!!! ASSERTION: JSEventListener has wrong script context?: 'stack && NS_SUCCEEDED(stack->Peek(&cx)) && cx && GetScriptContextFromJSContext(cx) == mContext', file /home/toddw/src/mozilla/src/trunk_debug_2/mozilla/dom/src/events/nsJSEventListener.cpp, line 244
Comment on attachment 306021 [details] [diff] [review] Add handling of the additional version argument That looks correct - no idea about the assertions yet though - probably a new bug should be opened?
Attachment #306021 - Flags: review?(mhammond) → review+
Okay, new bug started for the assertion error: bug 419968.
Comment on attachment 306021 [details] [diff] [review] Add handling of the additional version argument Small change to fix Python Dom event handling. Not part of the normal build.
Attachment #306021 - Flags: approval1.9b4?
Assignee: nobody → toddw
Status: UNCONFIRMED → NEW
Ever confirmed: true
This isn't part of the build. I'll just land it.
Status: NEW → ASSIGNED
Keywords: checkin-needed
Version: unspecified → Trunk
Attachment #306021 - Flags: approval1.9b4?
Checking in extensions/python/dom/src/nsPyContext.cpp; /cvsroot/mozilla/extensions/python/dom/src/nsPyContext.cpp,v <-- nsPyContext.cpp new revision: 1.11; previous revision: 1.10 done
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9beta4
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: