Skip to content

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

@aaaaalbert

Description

@aaaaalbert

Note: This was SeattleTestbed/repy_v2#60 previously. I'm just attaching it to the correct issue tracker, but have not reviewed it for aptness.


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().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions