Improvements to the package importing feature - test case will follow

llvm-svn: 181461
This commit is contained in:
Enrico Granata 2013-05-08 20:25:10 +00:00
parent 23f23f4b7a
commit e1432cfe4c
1 changed files with 14 additions and 4 deletions

View File

@ -2602,13 +2602,23 @@ ScriptInterpreterPython::LoadScriptingModule (const char* pathname,
Locker::AcquireLock | (init_session ? Locker::InitSession : 0),
Locker::FreeAcquiredLock | (init_session ? Locker::TearDownSession : 0));
if (target_file.GetFileType() == FileSpec::eFileTypeInvalid ||
target_file.GetFileType() == FileSpec::eFileTypeUnknown ||
target_file.GetFileType() == FileSpec::eFileTypeDirectory )
if (target_file.GetFileType() == FileSpec::eFileTypeDirectory)
{
// if not a filename, try to just plain import
// for directories, just import
basename = pathname;
}
else if (target_file.GetFileType() == FileSpec::eFileTypeInvalid ||
target_file.GetFileType() == FileSpec::eFileTypeUnknown)
{
// if not a valid file of any sort, check if it might be a filename still
// dot can't be used but / and \ can, and if either is found, reject
if (strchr(pathname,'\\') || strchr(pathname,'/'))
{
error.SetErrorString("invalid pathname");
return false;
}
basename = pathname; // not a filename, probably a package of some sort, let it go through
}
else
{
const char* directory = target_file.GetDirectory().GetCString();