Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

'name' can't be retrieved using getattr, always returns empty string #198

Open
pyjsorg opened this Issue · 6 comments

1 participant

pyjs.org
pyjs.org
Owner

Seems that 'name' is actually a specially reserved attribute, or conflicts with the internal JS object representation somehow. Trying to retrieve it with getattr always returns the empty string. Here's the sample code:

class TestClass(object):

def __init__( self ):

    self.name = 'foo'

test_class = TestClass()
my_name = getattr( test_class, 'name' )
print "my_name is: " + my_name
print "no, actually it is: " + test_class.name

Original issue: http://code.google.com/p/pyjamas/issues/detail?id=521 (November 23, 2010 18:53:23)

pyjs.org
Owner

From cornelis...@gmail.com on November 23, 2010 19:57:02:
Which pyjamas version are you using and what are the compile options?
Which browser (if any)?

I get the following output:
my_name is: foo
no, actually it is: foo

pyjs.org
Owner

From geoff.fl...@gmail.com on November 23, 2010 21:12:32:
I'm using the git head, I've reproduced the issue on a separate machine. Here's the last commit:

commit 4820424
Author: Kees Bos cornelis.bos@gmail.com
Date: Mon Nov 22 08:41:52 2010 +0100

Fixes issue 520 : Replaced eval() in sys.trackstackstr() with reference to
$pyjs.loaded_modules
pyjs.org
Owner

From geoff.fl...@gmail.com on November 23, 2010 21:48:13:
Oh, I was just using regular pyjsbuild with no args. Though generally I try to use --strict.

pyjs.org
Owner

From cornelis...@gmail.com on November 24, 2010 09:34:24:
I've tried with several options. I still can't reproduce this.

What I've tried:
rm output/lib/.js; ./pyjsbuild --no-compile-inplace -O --print test_getattr.py
rm output/lib/
.js; ./pyjsbuild --no-compile-inplace test_getattr.py
rm output/lib/*.js; ./pyjsbuild --no-compile-inplace --strict test_getattr.py

So, it should also work without --strict option. If you could provide more details to get to this problem, that s appreciated. (E.g. the test_getattr.js that's generated, assuming that you name your test file also test_getattr.py ;-) )

Which browser do you use?

pyjs.org
Owner

From cornelis...@gmail.com on January 31, 2012 11:20:55:
I was able to reproduce this with chrome.

This bug should be fixed (commit c06a123)

I'll close this ticket, unless you still see the problem.

pyjs.org
Owner

From luke.lei...@gmail.com on February 05, 2012 20:18:59:
apologies, kees - LibTest doesn't run (throws an exception with "CompileTest" no attribute named prototype) so i had to back this out (attached)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.