Import errors are obsured...

All other Source.Python topics and issues.
Omega_K2
Senior Member
Posts: 227
Joined: Sat Jul 07, 2012 3:05 am
Location: Europe
Contact:

Import errors are obsured...

Postby Omega_K2 » Fri Jun 28, 2013 11:23 am

If you try to do the following:

Load a script
Script imports a lib
lib also imports a nonworking file

You'll just get an ImportError for the first lib, not the others


just a heads up..
Libraries: k2tools
Plugins (any): GSRPG (soon) | Pretty Status List | MySQLAds (soon)
Plugins (game-specific): None atm

If you happen to find a bug or need help, either post in the release threads or contact me in IRC gamesurge.net:6667 / #sourcepython
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Fri Jun 28, 2013 2:26 pm

Could you give an example so that I can test for this? Please use pastebin to post the example until our syntax bbcode gets fixed.

Thanks for reporting,
Satoon
Omega_K2
Senior Member
Posts: 227
Joined: Sat Jul 07, 2012 3:05 am
Location: Europe
Contact:

Postby Omega_K2 » Fri Jun 28, 2013 7:34 pm

It seems to happen only with non-standard imports in packages (though I got it earlier with standard imports in a package, but I can't seem to replicate it again :S):

test2/test2.py

Syntax: Select all

from mypackage import derp


_libs/mypackage/derp.py

Syntax: Select all

__import__("This is gonna fail")


Error that shows up:

Syntax: Select all

ImportError: cannot import name derp
Libraries: k2tools

Plugins (any): GSRPG (soon) | Pretty Status List | MySQLAds (soon)

Plugins (game-specific): None atm



If you happen to find a bug or need help, either post in the release threads or contact me in IRC gamesurge.net:6667 / #sourcepython
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Fri Jun 28, 2013 7:54 pm

I'm not sure what to tell you. I assumed that "maybe" the issue was that we remove all lines that have "importlib" in them to reduce the spam within the exception printed. However, I placed some debugging messages prior to that happening, and I still get the exact same result. Maybe, instead of simply using __import__, you should use a try/except and print out (or simply raise) the exception yourself when the import fails. I am a little confused why this is happening, though. I will continue to investigate.

Satoon

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 57 guests