New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Location searchdict failure in IE #381

Open
pyjsorg opened this Issue Apr 27, 2012 · 9 comments

Comments

Projects
None yet
1 participant
@pyjsorg
Contributor

pyjsorg commented Apr 27, 2012

What steps will reproduce the problem?
1.Use Window.getLocation().getSearchVar("something") or any getSearch
method in IE.

What is the expected output? What do you see instead?

Always receive alert window with this message: "Module pyjamas.Location at
line 5: [object Error]" then another alert message: "Test TypeError:
'undefined' is null or not an object". I then do not receive expected
results (I do not receive my search vars for example). Note: Works great
in Firefox. This has also been tested using IE in Linux and Windows as
well as Firefox on Linux and Windows. IE is the culprit.

What version of Pyjamas are you using? which svn revision number?
On what operating system?

I am using pyjamas-0.7pre1 on Ubuntu Linux 9.04.

If using PyJS, have you attached a javascript stack trace,
from IE's Script Debugger or from Firefox Venkman / Firebug?
Have you attached a stack trace from using "-d" compiler option?

I did use the -d compiler.

If using PyJD, have you attached a python stack trace?

If using PyJS, what compiler options did you use?
-d -o

Please provide any additional information below.

I did some digging into this to see if I could fix it (and still will to
some degree). Line 73 in Location.py is the real culprit. The code takes
the results of self.location, which is valid at that point and does one of
these numbers on it (self.location[1:]). In IE (for whatever reason)
returns a null at this point.

Original issue: http://code.google.com/p/pyjamas/issues/detail?id=338 (November 24, 2009 14:01:18)

@pyjsorg

This comment has been minimized.

Show comment
Hide comment
@pyjsorg

pyjsorg Apr 27, 2012

Contributor

From chris.fr...@gmail.com on November 24, 2009 14:53:12:
FYI, I have tested this error in IE 6 and IE 8 with the same error.
FYI, I have tested this error in IE 6 and IE 8 with the same error.

I have been messing with this a bit more and accidentally discovered something. I
think the problem is the "s" parameter in the makeUrlDict (Location.py line 3)
function could be some kind of secret global keyword in IE. I started by moving the
makeUrlDict functionality into the getSearchDict method and discovered that it was
working fine in there. The problem was happening in the passing of the parameter
into the function. Call the function and it is fine but in the function it is null.
I changed the name of the parameter for s to urlstring and it works perfectly.

I have attached my version.

Contributor

pyjsorg commented Apr 27, 2012

From chris.fr...@gmail.com on November 24, 2009 14:53:12:
FYI, I have tested this error in IE 6 and IE 8 with the same error.
FYI, I have tested this error in IE 6 and IE 8 with the same error.

I have been messing with this a bit more and accidentally discovered something. I
think the problem is the "s" parameter in the makeUrlDict (Location.py line 3)
function could be some kind of secret global keyword in IE. I started by moving the
makeUrlDict functionality into the getSearchDict method and discovered that it was
working fine in there. The problem was happening in the passing of the parameter
into the function. Call the function and it is fine but in the function it is null.
I changed the name of the parameter for s to urlstring and it works perfectly.

I have attached my version.

@pyjsorg

This comment has been minimized.

Show comment
Hide comment
@pyjsorg

pyjsorg Apr 27, 2012

Contributor

From luke.lei...@gmail.com on November 24, 2009 20:49:17:
please update to latest svn when making bugreports, we do not do anything other than
latest svn bugfixes. thanks.

Contributor

pyjsorg commented Apr 27, 2012

From luke.lei...@gmail.com on November 24, 2009 20:49:17:
please update to latest svn when making bugreports, we do not do anything other than
latest svn bugfixes. thanks.

@pyjsorg

This comment has been minimized.

Show comment
Hide comment
@pyjsorg

pyjsorg Apr 27, 2012

Contributor

From luke.lei...@gmail.com on November 26, 2009 15:30:26:
interesting. this is the second instance where breaking down statements into
individual statements has "fixed" a "problem" in IE.

one for kees.

so - thank you for highlighting this, chris. for future reference, diff -u patches
are infinitely preferable to dumping entire copies of existing code at people: i had
to manually use "diff" myself to ascertain that there were only 5 lines changed.

@@ -1,8 +1,8 @@
from pyjamas import JS

-def makeUrlDict(s):
+def makeUrlDict(urlstring):
dict = {}

  • pairs = s.split("&")

  • pairs = urlstring.split("&")
    for pair in pairs:
    if len(pair) < 3: continue
    kv = pair.split("=",1)
    @@ -70,7 +70,9 @@ class Location:
    if isinstance(self.location, str):
    return {}
    if not self.searchDict:

  •        self.searchDict = makeUrlDict(self.getSearch()[1:])
    
  •        self.searchDict = {}
    
  •        search = self.getSearch()[1:]
    
  •        self.searchDict = makeUrlDict(search)
     return self.searchDict
    

    def getSearchVar(self, key):

Contributor

pyjsorg commented Apr 27, 2012

From luke.lei...@gmail.com on November 26, 2009 15:30:26:
interesting. this is the second instance where breaking down statements into
individual statements has "fixed" a "problem" in IE.

one for kees.

so - thank you for highlighting this, chris. for future reference, diff -u patches
are infinitely preferable to dumping entire copies of existing code at people: i had
to manually use "diff" myself to ascertain that there were only 5 lines changed.

@@ -1,8 +1,8 @@
from pyjamas import JS

-def makeUrlDict(s):
+def makeUrlDict(urlstring):
dict = {}

  • pairs = s.split("&")

  • pairs = urlstring.split("&")
    for pair in pairs:
    if len(pair) < 3: continue
    kv = pair.split("=",1)
    @@ -70,7 +70,9 @@ class Location:
    if isinstance(self.location, str):
    return {}
    if not self.searchDict:

  •        self.searchDict = makeUrlDict(self.getSearch()[1:])
    
  •        self.searchDict = {}
    
  •        search = self.getSearch()[1:]
    
  •        self.searchDict = makeUrlDict(search)
     return self.searchDict
    

    def getSearchVar(self, key):

@pyjsorg

This comment has been minimized.

Show comment
Hide comment
@pyjsorg

pyjsorg Apr 27, 2012

Contributor

From cornelis...@gmail.com on December 02, 2009 07:44:03:
Hmm. I need some help on this problem to reproduce it.

I reverted the change in getSearchDict()
def getSearchDict(self):
if isinstance(self.location, str):
return {}
if not self.searchDict:
self.searchDict = makeUrlDict(self.getSearch()[1:])
#self.searchDict = {}
#search = self.getSearch()[1:]
#self.searchDict = makeUrlDict(search)
return self.searchDict

and added a test to the helloworld example:
if name == 'main':
pyjd.setup("public/Hello.html?fred=foo#me")
svar = Window.getLocation().getSearchVar("fred")
Window.alert(repr(svar))

and used the url ... output/Hello.html?fred=foo#me

On IE6/IE8 I get the alert with content 'foo'

(See attachment for patch to svn that I used for the test)

Contributor

pyjsorg commented Apr 27, 2012

From cornelis...@gmail.com on December 02, 2009 07:44:03:
Hmm. I need some help on this problem to reproduce it.

I reverted the change in getSearchDict()
def getSearchDict(self):
if isinstance(self.location, str):
return {}
if not self.searchDict:
self.searchDict = makeUrlDict(self.getSearch()[1:])
#self.searchDict = {}
#search = self.getSearch()[1:]
#self.searchDict = makeUrlDict(search)
return self.searchDict

and added a test to the helloworld example:
if name == 'main':
pyjd.setup("public/Hello.html?fred=foo#me")
svar = Window.getLocation().getSearchVar("fred")
Window.alert(repr(svar))

and used the url ... output/Hello.html?fred=foo#me

On IE6/IE8 I get the alert with content 'foo'

(See attachment for patch to svn that I used for the test)

@pyjsorg

This comment has been minimized.

Show comment
Hide comment
@pyjsorg

pyjsorg Apr 27, 2012

Contributor

From cornelis...@gmail.com on December 02, 2009 08:06:23:
Looking at the generated code doesn't give me a clue eighter.

(a)
pyjslib['setattr'](self, 'searchDict',
Location['makeUrlDict']%28pyjslib['slice']%28self['getSearch']%28), 1, null)));

(b)
pyjslib['setattr'](self, 'searchDict', pyjslib['Dict']%28[]));
search = pyjslib['slice'](self['getSearch']%28%29, 1, null);
pyjslib['setattr'](self, 'searchDict', Location['makeUrlDict']%28search));

Contributor

pyjsorg commented Apr 27, 2012

From cornelis...@gmail.com on December 02, 2009 08:06:23:
Looking at the generated code doesn't give me a clue eighter.

(a)
pyjslib['setattr'](self, 'searchDict',
Location['makeUrlDict']%28pyjslib['slice']%28self['getSearch']%28), 1, null)));

(b)
pyjslib['setattr'](self, 'searchDict', pyjslib['Dict']%28[]));
search = pyjslib['slice'](self['getSearch']%28%29, 1, null);
pyjslib['setattr'](self, 'searchDict', Location['makeUrlDict']%28search));

@pyjsorg

This comment has been minimized.

Show comment
Hide comment
@pyjsorg

pyjsorg Apr 27, 2012

Contributor

From luke.lei...@gmail.com on December 02, 2009 09:07:19:
tell you what: we have at least a "partial" solution, enough to not stop a release.
if more info can be given, great.

Contributor

pyjsorg commented Apr 27, 2012

From luke.lei...@gmail.com on December 02, 2009 09:07:19:
tell you what: we have at least a "partial" solution, enough to not stop a release.
if more info can be given, great.

@pyjsorg

This comment has been minimized.

Show comment
Hide comment
@pyjsorg

pyjsorg Apr 27, 2012

Contributor

From cornelis...@gmail.com on December 02, 2009 09:30:55:
OK. I'm really worried with this problem though. So, Chris, if you could help me,
that would be great. Either with finding a reproducible test case or, if I can't
reproduce it and you can, by applying changes to the generated javascript code.

Contributor

pyjsorg commented Apr 27, 2012

From cornelis...@gmail.com on December 02, 2009 09:30:55:
OK. I'm really worried with this problem though. So, Chris, if you could help me,
that would be great. Either with finding a reproducible test case or, if I can't
reproduce it and you can, by applying changes to the generated javascript code.

@pyjsorg

This comment has been minimized.

Show comment
Hide comment
@pyjsorg

pyjsorg Apr 27, 2012

Contributor

From Matthew.Cahn@gmail.com on February 12, 2010 18:35:56:
I can confirm that this error occured for me in IE 6, under WinXP SP2, with Pyjamas
0.7pre1; and that after updating to Pyjamas 0.7pre2 svn revision 2397 it now works.

Contributor

pyjsorg commented Apr 27, 2012

From Matthew.Cahn@gmail.com on February 12, 2010 18:35:56:
I can confirm that this error occured for me in IE 6, under WinXP SP2, with Pyjamas
0.7pre1; and that after updating to Pyjamas 0.7pre2 svn revision 2397 it now works.

@pyjsorg

This comment has been minimized.

Show comment
Hide comment
@pyjsorg

pyjsorg Apr 27, 2012

Contributor

From luke.lei...@gmail.com on February 12, 2010 18:55:01:
thanks matthew

Contributor

pyjsorg commented Apr 27, 2012

From luke.lei...@gmail.com on February 12, 2010 18:55:01:
thanks matthew

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment