I pushed an attempted fix in r286254.

I wonder if this is a difference between python 2.7 and 3. The comprehension 
should capture everything, as should the eval call. I wonder if one of those 
captures less in python 3 compared to python 2.7.

Hopefully my patch will resolve the issue for you.

-Chris

> On Nov 8, 2016, at 7:37 AM, Zachary Turner <ztur...@google.com> wrote:
> 
> 
> 
> On Sun, Oct 30, 2016 at 9:57 PM Chris Bieneman via lldb-commits 
> <lldb-commits@lists.llvm.org <mailto:lldb-commits@lists.llvm.org>> wrote:
> 
> Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py?rev=285542&r1=285541&r2=285542&view=diff
>  
> <http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py?rev=285542&r1=285541&r2=285542&view=diff>
> ==============================================================================
> --- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py (original)
> +++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py Sun Oct 30 23:48:19 
> 2016
> @@ -1848,6 +1848,33 @@ class TestBase(Base):
>                  folder = os.path.dirname(folder)
>                  continue
> 
> +    def generateSource(self, source):
> +        template = source + '.template'
> +        temp = os.path.join(os.getcwd(), template)
> +        with open(temp, 'r') as f:
> +            content = f.read()
> +
> +        public_api_dir = os.path.join(
> +            os.environ["LLDB_SRC"], "include", "lldb", "API")
> +
> +        # Look under the include/lldb/API directory and add #include 
> statements
> +        # for all the SB API headers.
> +        public_headers = os.listdir(public_api_dir)
> +        # For different platforms, the include statement can vary.
> +        if self.hasDarwinFramework():
> +            include_stmt = "'#include <%s>' % os.path.join('LLDB', header)"
> +        else:
> +            include_stmt = "'#include <%s>' % os.path.join(public_api_dir, 
> header)"
> +        list = [eval(include_stmt) for header in public_headers if (
> +            header.startswith("SB") and header.endswith(".h"))]
> +        includes = '\n'.join(list)
> +        new_content = content.replace('%include_SB_APIs%', includes)
> +        src = os.path.join(os.getcwd(), source)
> +        with open(src, 'w') as f:
> +            f.write(new_content)
> +
> +        self.addTearDownHook(lambda: os.remove(src))
> +
> 
> The non hasDarwinFramework codepath is broken here, and I don't believe it to 
> be a Windows specific issue.  I'm getting the following error in multiple 
> tests.
> 
> Traceback (most recent call last):
>   File 
> "C:\src\llvm\tools\lldb\packages\Python\lldbsuite\test\functionalities\plugins\commands\TestPluginCommands.py",
>  line 23, in setUp
>     self.generateSource('plugin.cpp')
>   File "C:\src\llvm\tools\lldb\packages\Python\lldbsuite\test\lldbtest.py", 
> line 1868, in generateSource
>     list = [eval(include_stmt) for header in public_headers if (
>   File "C:\src\llvm\tools\lldb\packages\Python\lldbsuite\test\lldbtest.py", 
> line 1869, in <listcomp>
>     header.startswith("SB") and header.endswith(".h"))]
>   File "<string>", line 1, in <module>
> NameError: name 'public_api_dir' is not defined
> Config=i686-C:\src\llvmbuild\ninja_release\bin\clang.exe 
> 
> I'm hypothesizing that the problem is that from inside of a list 
> comprehension, your set of locals is not the same as outside of the list 
> comprehension, and so the eval statement does not see the variable 
> `public_api_dir`.  Is there any way you could provide a fix for this?

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to