-
Notifications
You must be signed in to change notification settings - Fork 337
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
@include: Only include modules from the current package #1485
@include: Only include modules from the current package #1485
Conversation
088b530
to
35336f7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix @SitiSchu! Do you think you could add a simple unit tests there to make sure this is well covered?
Note to TSC: CLA is correctly signed and setup. I'm not too sure why the EasyCLA bot didn't create a comment. I checked in PCC and I see the signature, so everything is good. |
@JeanChristopheMorinPerso Sure can do, what would you like tested? I guess making sure it doesn't actually end up in |
I'd test get_module_from_file, which basically means testing that I can import from a given file and that it doesn't end up in sys.modules. |
f3f4b92
to
78c3f34
Compare
I've added a test case for this. To make sure it works, I ran the test without my fix and it did fail correctly. |
It looks like the test fails with Python 2.7, should I limit the test to Python 3 only or should I try and fix the issue for py2 too(despite it being deprecated for years now)? |
We need to support both python 2 and 3. So if we fix python 3, we also need a fix for py 2. |
Locally the copyright fix added a empty line to the utils file which made git complain about the extra whitespace. So I added a comment. Now it doesn't complain locally anymore but somehow the CI still fails. |
Don't worry about this check for now. We can take care of that. Thanks for adding a test! |
…Foundation#1483 Signed-off-by: SitiSchu <admin@sitischu.com>
Signed-off-by: SitiSchu <admin@sitischu.com>
Signed-off-by: SitiSchu <admin@sitischu.com>
Signed-off-by: SitiSchu <admin@sitischu.com>
1104747
to
a69c049
Compare
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
There you go @SitiSchu. I fixed the copyright issue. I remove the dummy python module and I'm now creating it on the fly in the tests. I wasn't able to find why the change_copyright isn't doing what it's supposed to. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks a lot for this!
Thanks you @SitiSchu ! |
Fixes #1483
The previously used
SourceFileLoader(name, filepath).load_module()
adds the imported module tosys.modules
. When a second module is imported with the same name, the previous module gets overwritten. In the case of #1483 this happened:sys.modules
sys.modules
which causes the module cache to now have Pkg B's utils for allutils
hashesutils
modules so this returns Pkg B's utils.Using
importlib.util.module_from_spec
avoids this by not adding imported modules tosys.modules
so nothing gets overwritten even if modules with the same name get imported multiple times.Since the
@include
functionality works by placing the module in theglobals
forexec
, not having the module insys.modules
should be fine.