This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Unconditionally strip the `.py(c)` extension as we always import Python modules
ClosedPublic

Authored by JDevlieghere on Oct 13 2020, 4:59 PM.

Details

Summary

Currently we only strip the Python extension when the file exists on disk because we assumed that if it didn't exist it was a module. However, with the change from D89334 this is no longer the case as we want to be able to import a relative path to a .py as a module. Since we always import a scripting module as a "python module" we should always strip the extension if present.

This is necessary to write a test with a .py extension as suggested by Dave:

Would you mind adding a couple tests for imports via a path to a python file, ex command script import command.py, maybe even a test that checks nested directories, ex: command script import path/to/command.py?

Diff Detail

Event Timeline

JDevlieghere requested review of this revision.Oct 13 2020, 4:59 PM
JDevlieghere created this revision.
kastiglione accepted this revision.Oct 13 2020, 7:26 PM
This revision is now accepted and ready to land.Oct 13 2020, 7:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 13 2020, 11:51 PM