[Lldb-commits] [lldb] r251886 - Tighten up sys.path, and use absolute imports everywhere.
Todd Fiala via lldb-commits
lldb-commits at lists.llvm.org
Mon Nov 2 22:28:47 PST 2015
No, we won't need/want to revert. I just wanted to see if you already had
a snazzy script I could whiz through a directory tree with.
-Todd
On Mon, Nov 2, 2015 at 10:26 PM, Zachary Turner <zturner at google.com> wrote:
> Also, one last thing. The reason this is probably wreaking havoc on your
> stuff internally is because I removed scriptDir from sys.path (diff the
> changes of dotest.py to see). I think it should stay removed upstream
> (mucking with sys.path so you can import from a parent directory is a bad
> thing to do), but if you have a fork it might be worth putting it back into
> the fork temporarily to get things green? Note that technically stuff will
> still be "broken" the same way it was before (importing a second copy of a
> module), but that only ever leads to an actual problem fi you rely on
> global state from the module - which upstream anyway we were only ever
> doing for lldbtest_config.
>
> If worse comes to worse we can revert, but if so I think somehow we should
> figure out a strategy for getting this back in, because it definitely seems
> like "the right way"
>
> On Mon, Nov 2, 2015 at 10:14 PM Zachary Turner <zturner at google.com> wrote:
>
>> Also as far as I can tell, X has to be in the following set: [lldbutil,
>> lldbtest, lldbinline, lldbbench]. In theory there are other possibilities
>> (any .py file that is in packages/Python/lldbsuite/test is fair game) but I
>> don't think I encountered any aside from those 4.
>>
>> On Mon, Nov 2, 2015 at 10:12 PM Zachary Turner <zturner at google.com>
>> wrote:
>>
>>> On Mon, Nov 2, 2015 at 10:02 PM Todd Fiala <todd.fiala at gmail.com> wrote:
>>>
>>>> Do you have a script you used to tweak these?
>>>>
>>>> (We have a ton of stuff broken internally on this that I need to fix
>>>> up).
>>>>
>>>> We're starting to need to do quite a bit of extra typing for the
>>>> package structure :-/
>>>>
>>>
>>> No, I just used a recursive regex replacement. I had to find a few
>>> different patterns:
>>>
>>> from X import foo # from lldbsuite.test.X import foo
>>> import X # import lldbsuite.test.X as X
>>> import foo, X #import foo\nimport lldbsuite.test.X as X
>>>
>>> and I handled each one on a case-by-case basis.
>>>
>>> Luckily the extra typing only comes at the import site. If you use the
>>> syntax I suggested in #2 and #3 above (import lldbsuite.test.X as X) then
>>> the syntax at any sites where you use a definition from inside the module
>>> are the same.
>>>
>>> I was a little bit annoyed at the extra typing myself, but when I look
>>> into it, it's considered a "feature". See PEP 0328 - Imports:
>>> Multi-Line and Absolute/Relative
>>> <https://www.python.org/dev/peps/pep-0328/> and as far as I can tell
>>> the way we were doing things before was considered "wrong" :(
>>>
>>> How much of a problem is this going to be on your side? Is there an
>>> equally "good" solution that doesn't require so much fixup on your side?
>>>
>>> the only fixup I encountered was in individual test cases and test
>>> suites (i.e. files that are loaded by unittest2). Does this account for
>>> all the test failures on your side as well, or is there something else
>>> going on I missed?
>>>
>>
--
-Todd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20151102/78bc5ebf/attachment.html>
More information about the lldb-commits
mailing list