Ronald Oussoren added the comment:

In foo2.py you import "a.foo", which refers to module 'a' that isn't included 
in the directory structure you describe.  I'm assuming 'dirc' should be 'a' to 
match the code.

How did you run foo1.py?  

When running with 'python3.6 -m bug.foo1' I get an error about not being able 
to import 'a' (as expected, the package is 'bug.a').

When you run with "PYTHONPATH=. python3.6 bug/foo1.py" I get the assertion 
failure you mention, and that's expected behavior.  This gets clearer when you 
print type(fun()) and Event, the output will be:

  <class 'a.foo.Event'>
  <class 'bug.a.foo.Event'>

As you can see these refer to two different classes, not the same class.

The reason for this is that  'python3.6 bug/foo1.py' adds the 'bug' directory 
to the start of sys.path, hence the "import a.foo" in foo2 succeeds. The script 
foo1.py imports 'bug.a.foo', which is a different name that happens to refer to 
the same file on the filesystem.

All in all this is expected behavior and not a bug.

----------
resolution:  -> not a bug
status: open -> pending

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue30888>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to