This is an archive of the discontinued LLVM Phabricator instance.

Fix TestImport for Windows by ensuring backslashes in the directory paths are properly escaped in Python.
ClosedPublic

Authored by amccarth on Apr 7 2016, 3:37 PM.

Details

Summary

The Python import works by ensuring the directory of the module or package is in sys.path, and then it does a Python import foo. The original code was not escaping the backslashes in the directory path, so this wasn't working.

(Discovered after chasing alternative ways of importing a module from a path.)

Diff Detail

Repository
rL LLVM

Event Timeline

amccarth updated this revision to Diff 52963.Apr 7 2016, 3:37 PM
amccarth retitled this revision from to Fix TestImport for Windows by ensuring backslashes in the directory paths are properly escaped in Python..
amccarth updated this object.
amccarth added a reviewer: zturner.
zturner accepted this revision.Apr 7 2016, 3:44 PM
zturner edited edge metadata.

Just occurred to me that it would be nice if PythonDataObjects exposed a way to get the underlying PythonObject of various common globals like sys.path etc. Then we could just do something like

PythonDataObjects::QuickVars::SysPath.Insert(0, Escape(directory));

But, that's outside the scope of this patch, so lgtm.

This revision is now accepted and ready to land.Apr 7 2016, 3:44 PM
This revision was automatically updated to reflect the committed changes.