SeattleTestbed / attic

ARCHIVAL: Full mirror of SeattleTestbed's SVN in early 2014. We use GitHub since!
MIT License
0 stars 1 forks source link

Dylink doesn't allow us to call functions that start with '_' #1386

Open choksi81 opened 10 years ago

choksi81 commented 10 years ago

If we import a file using dylink, it won't allow us to call functions that start with an underscore. This is different from how python import works. Not sure if this is an intended behaviour or not. Below is a piece of code that fails.

foo.py:

def _foo():
    print "foo"

bar.py:

from repyportability import *
add_dy_support(locals())

foo = dy_import_module("foo.py")

try:
  foo._foo()
except AttributeError, err:
  print "Unable to call foo._foo() when using dylink.\n" + str(err)

import foo
foo._foo()

If we run bar.py, we get the following error when calling foo._foo() (when using dylink):

monzum@TestUbuntu:$ python bar.py 
Unable to call foo._foo() when using dylink.
ImportedModule instance has no attribute '_foo'

However once we use 'import' to import it, we are able to call foo._foo().