Patchwork [3,of,3,V2] test-pyflakes: detect undefined name error

login
register
mail settings
Submitter Yuya Nishihara
Date May 2, 2014, 10:14 a.m.
Message ID <b7b37547eec4246671f7.1399025677@gimlet>
Download mbox | patch
Permalink /patch/4494/
State Accepted
Commit 0768cda8b5799dc803dc0ee27a832cd64e05f28a
Headers show

Comments

Yuya Nishihara - May 2, 2014, 10:14 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1398743641 -32400
#      Tue Apr 29 12:54:01 2014 +0900
# Node ID b7b37547eec4246671f7ae28843a6931813b810d
# Parent  de513875f008f333f320aca0b236b6e8af54cdbf
test-pyflakes: detect undefined name error

It should be able to catch the following mistakes at 2606e7f227f6:

    mercurial/exchange.py:590: undefined name 'UnknownPartError'
    mercurial/match.py:346: undefined name 'pat'
    mercurial/win32.py:365: undefined name '_ERROR_NO_MORE_FILES'
    tests/killdaemons.py:46: undefined name 'check'
Matt Mackall - May 6, 2014, 7:04 p.m.
On Fri, 2014-05-02 at 19:14 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1398743641 -32400
> #      Tue Apr 29 12:54:01 2014 +0900
> # Node ID b7b37547eec4246671f7ae28843a6931813b810d
> # Parent  de513875f008f333f320aca0b236b6e8af54cdbf
> test-pyflakes: detect undefined name error

These are queued for default, thanks.
Katsunori FUJIWARA - May 8, 2014, 4:25 p.m.
At Fri, 02 May 2014 19:14:37 +0900,
Yuya Nishihara wrote:
> 
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1398743641 -32400
> #      Tue Apr 29 12:54:01 2014 +0900
> # Node ID b7b37547eec4246671f7ae28843a6931813b810d
> # Parent  de513875f008f333f320aca0b236b6e8af54cdbf
> test-pyflakes: detect undefined name error
> 
> It should be able to catch the following mistakes at 2606e7f227f6:
> 
>     mercurial/exchange.py:590: undefined name 'UnknownPartError'
>     mercurial/match.py:346: undefined name 'pat'
>     mercurial/win32.py:365: undefined name '_ERROR_NO_MORE_FILES'
>     tests/killdaemons.py:46: undefined name 'check'
> 
> diff --git a/tests/filterpyflakes.py b/tests/filterpyflakes.py
> --- a/tests/filterpyflakes.py
> +++ b/tests/filterpyflakes.py
> @@ -32,6 +32,7 @@ for line in sys.stdin:
>              r"imported but unused",
>              r"local variable '.*' is assigned to but never used",
>              r"unable to detect undefined names",
> +            r"undefined name '.*'",
>             ]
>      for msgtype, pat in enumerate(pats):
>          if re.search(pat, line):

According to my bisect-ing, this change (0768cda8b579 in master repo)
seems to break "test-check-pyflakes.t" as below:

    ====================
    @@ -17,5 +17,7 @@
       tests/hghave.py:*: 'pygments' imported but unused (glob)
       tests/hghave.py:*: 'ssl' imported but unused (glob)
       contrib/win32/hgwebdir_wsgi.py:93: 'from isapi.install import *' used; unable to detect undefined names (glob)
    +  mercurial/util.py:116: undefined name 'memoryview'
    +  mercurial/windows.py:34: undefined name 'WindowsError'
    
     #endif
    ====================

Is this failure specific to my environment (python 2.6.6 on debian
2.6.32), or just expected failure ?

----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy@lares.dti.ne.jp
Matt Mackall - May 8, 2014, 4:34 p.m.
On Fri, 2014-05-09 at 01:25 +0900, FUJIWARA Katsunori wrote:
> At Fri, 02 May 2014 19:14:37 +0900,
> Yuya Nishihara wrote:
> > 
> > # HG changeset patch
> > # User Yuya Nishihara <yuya@tcha.org>
> > # Date 1398743641 -32400
> > #      Tue Apr 29 12:54:01 2014 +0900
> > # Node ID b7b37547eec4246671f7ae28843a6931813b810d
> > # Parent  de513875f008f333f320aca0b236b6e8af54cdbf
> > test-pyflakes: detect undefined name error
> > 
> > It should be able to catch the following mistakes at 2606e7f227f6:
> > 
> >     mercurial/exchange.py:590: undefined name 'UnknownPartError'
> >     mercurial/match.py:346: undefined name 'pat'
> >     mercurial/win32.py:365: undefined name '_ERROR_NO_MORE_FILES'
> >     tests/killdaemons.py:46: undefined name 'check'
> > 
> > diff --git a/tests/filterpyflakes.py b/tests/filterpyflakes.py
> > --- a/tests/filterpyflakes.py
> > +++ b/tests/filterpyflakes.py
> > @@ -32,6 +32,7 @@ for line in sys.stdin:
> >              r"imported but unused",
> >              r"local variable '.*' is assigned to but never used",
> >              r"unable to detect undefined names",
> > +            r"undefined name '.*'",
> >             ]
> >      for msgtype, pat in enumerate(pats):
> >          if re.search(pat, line):
> 
> According to my bisect-ing, this change (0768cda8b579 in master repo)
> seems to break "test-check-pyflakes.t" as below:
> 
>     ====================
>     @@ -17,5 +17,7 @@
>        tests/hghave.py:*: 'pygments' imported but unused (glob)
>        tests/hghave.py:*: 'ssl' imported but unused (glob)
>        contrib/win32/hgwebdir_wsgi.py:93: 'from isapi.install import *' used; unable to detect undefined names (glob)
>     +  mercurial/util.py:116: undefined name 'memoryview'
>     +  mercurial/windows.py:34: undefined name 'WindowsError'
>     
>      #endif
>     ====================
> 
> Is this failure specific to my environment (python 2.6.6 on debian
> 2.6.32), or just expected failure ?

Probably a version issue, possibly with pyflakes.
Katsunori FUJIWARA - May 8, 2014, 5:35 p.m.
At Thu, 08 May 2014 11:34:55 -0500,
Matt Mackall wrote:
> 
> On Fri, 2014-05-09 at 01:25 +0900, FUJIWARA Katsunori wrote:
> > At Fri, 02 May 2014 19:14:37 +0900,
> > Yuya Nishihara wrote:
> > > 
> > > # HG changeset patch
> > > # User Yuya Nishihara <yuya@tcha.org>
> > > # Date 1398743641 -32400
> > > #      Tue Apr 29 12:54:01 2014 +0900
> > > # Node ID b7b37547eec4246671f7ae28843a6931813b810d
> > > # Parent  de513875f008f333f320aca0b236b6e8af54cdbf
> > > test-pyflakes: detect undefined name error
> > > 
> > > It should be able to catch the following mistakes at 2606e7f227f6:
> > > 
> > >     mercurial/exchange.py:590: undefined name 'UnknownPartError'
> > >     mercurial/match.py:346: undefined name 'pat'
> > >     mercurial/win32.py:365: undefined name '_ERROR_NO_MORE_FILES'
> > >     tests/killdaemons.py:46: undefined name 'check'
> > > 
> > > diff --git a/tests/filterpyflakes.py b/tests/filterpyflakes.py
> > > --- a/tests/filterpyflakes.py
> > > +++ b/tests/filterpyflakes.py
> > > @@ -32,6 +32,7 @@ for line in sys.stdin:
> > >              r"imported but unused",
> > >              r"local variable '.*' is assigned to but never used",
> > >              r"unable to detect undefined names",
> > > +            r"undefined name '.*'",
> > >             ]
> > >      for msgtype, pat in enumerate(pats):
> > >          if re.search(pat, line):
> > 
> > According to my bisect-ing, this change (0768cda8b579 in master repo)
> > seems to break "test-check-pyflakes.t" as below:
> > 
> >     ====================
> >     @@ -17,5 +17,7 @@
> >        tests/hghave.py:*: 'pygments' imported but unused (glob)
> >        tests/hghave.py:*: 'ssl' imported but unused (glob)
> >        contrib/win32/hgwebdir_wsgi.py:93: 'from isapi.install import *' used; unable to detect undefined names (glob)
> >     +  mercurial/util.py:116: undefined name 'memoryview'
> >     +  mercurial/windows.py:34: undefined name 'WindowsError'
> >     
> >      #endif
> >     ====================
> > 
> > Is this failure specific to my environment (python 2.6.6 on debian
> > 2.6.32), or just expected failure ?
> 
> Probably a version issue, possibly with pyflakes.

Thanks. I also remembered the thread about pyflakes version problem
below, and tried to use recent pyflakes:

    http://thread.gmane.org/gmane.comp.version-control.mercurial.devel/68364/focus=68385

Then, pyflakes 0.8.1 can avoid "undefined name 'WindowsError'", but
not "undefined name 'memoryview'" yet:

    ====================
    @@ -17,5 +17,6 @@
       tests/hghave.py:*: 'pygments' imported but unused (glob)
       tests/hghave.py:*: 'ssl' imported but unused (glob)
       contrib/win32/hgwebdir_wsgi.py:93: 'from isapi.install import *' used; unable to detect undefined names (glob)
    +  mercurial/util.py:116: undefined name 'memoryview'
    
     #endif
    ====================

Is the reason of this failure that "memoryview" is not available on
python 2.6.x ?

----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy@lares.dti.ne.jp
Katsunori FUJIWARA - May 8, 2014, 9:35 p.m.
At Fri, 09 May 2014 02:35:35 +0900,
FUJIWARA Katsunori wrote:
> 
> 
> At Thu, 08 May 2014 11:34:55 -0500,
> Matt Mackall wrote:
> > 
> > On Fri, 2014-05-09 at 01:25 +0900, FUJIWARA Katsunori wrote:
> > > At Fri, 02 May 2014 19:14:37 +0900,
> > > Yuya Nishihara wrote:
> > > > 
> > > > # HG changeset patch
> > > > # User Yuya Nishihara <yuya@tcha.org>
> > > > # Date 1398743641 -32400
> > > > #      Tue Apr 29 12:54:01 2014 +0900
> > > > # Node ID b7b37547eec4246671f7ae28843a6931813b810d
> > > > # Parent  de513875f008f333f320aca0b236b6e8af54cdbf
> > > > test-pyflakes: detect undefined name error
> > > > 
> > > > It should be able to catch the following mistakes at 2606e7f227f6:
> > > > 
> > > >     mercurial/exchange.py:590: undefined name 'UnknownPartError'
> > > >     mercurial/match.py:346: undefined name 'pat'
> > > >     mercurial/win32.py:365: undefined name '_ERROR_NO_MORE_FILES'
> > > >     tests/killdaemons.py:46: undefined name 'check'
> > > > 
> > > > diff --git a/tests/filterpyflakes.py b/tests/filterpyflakes.py
> > > > --- a/tests/filterpyflakes.py
> > > > +++ b/tests/filterpyflakes.py
> > > > @@ -32,6 +32,7 @@ for line in sys.stdin:
> > > >              r"imported but unused",
> > > >              r"local variable '.*' is assigned to but never used",
> > > >              r"unable to detect undefined names",
> > > > +            r"undefined name '.*'",
> > > >             ]
> > > >      for msgtype, pat in enumerate(pats):
> > > >          if re.search(pat, line):
> > > 
> > > According to my bisect-ing, this change (0768cda8b579 in master repo)
> > > seems to break "test-check-pyflakes.t" as below:
> > > 
> > >     ====================
> > >     @@ -17,5 +17,7 @@
> > >        tests/hghave.py:*: 'pygments' imported but unused (glob)
> > >        tests/hghave.py:*: 'ssl' imported but unused (glob)
> > >        contrib/win32/hgwebdir_wsgi.py:93: 'from isapi.install import *' used; unable to detect undefined names (glob)
> > >     +  mercurial/util.py:116: undefined name 'memoryview'
> > >     +  mercurial/windows.py:34: undefined name 'WindowsError'
> > >     
> > >      #endif
> > >     ====================
> > > 
> > > Is this failure specific to my environment (python 2.6.6 on debian
> > > 2.6.32), or just expected failure ?
> > 
> > Probably a version issue, possibly with pyflakes.
> 
> Thanks. I also remembered the thread about pyflakes version problem
> below, and tried to use recent pyflakes:
> 
>     http://thread.gmane.org/gmane.comp.version-control.mercurial.devel/68364/focus=68385
> 
> Then, pyflakes 0.8.1 can avoid "undefined name 'WindowsError'", but
> not "undefined name 'memoryview'" yet:
> 
>     ====================
>     @@ -17,5 +17,6 @@
>        tests/hghave.py:*: 'pygments' imported but unused (glob)
>        tests/hghave.py:*: 'ssl' imported but unused (glob)
>        contrib/win32/hgwebdir_wsgi.py:93: 'from isapi.install import *' used; unable to detect undefined names (glob)
>     +  mercurial/util.py:116: undefined name 'memoryview'
>     
>      #endif
>     ====================
> 
> Is the reason of this failure that "memoryview" is not available on
> python 2.6.x ?

I confirmed that pyflakes doesn't show "undefined name 'memoryview'"
on Python 2.7.x.

I'll send the patch to care Python version.

BTW, updating pyflakes on my environment can detect "undefined name"
problem introduced by my patch 49148d7868df :-<

I'll also send the patch for this quickly.


----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy@lares.dti.ne.jp

Patch

diff --git a/tests/filterpyflakes.py b/tests/filterpyflakes.py
--- a/tests/filterpyflakes.py
+++ b/tests/filterpyflakes.py
@@ -32,6 +32,7 @@  for line in sys.stdin:
             r"imported but unused",
             r"local variable '.*' is assigned to but never used",
             r"unable to detect undefined names",
+            r"undefined name '.*'",
            ]
     for msgtype, pat in enumerate(pats):
         if re.search(pat, line):