[Python-apps-commits] r10371 - in packages/pyflakes/trunk/debian (5 files)

xnox at users.alioth.debian.org xnox at users.alioth.debian.org
Mon Jan 20 23:00:07 UTC 2014


    Date: Monday, January 20, 2014 @ 23:00:06
  Author: xnox
Revision: 10371

Cherry-pick 17 upstream commits since 0.7.3, to add python 3.4
support.

Added:
  packages/pyflakes/trunk/debian/patches/
  packages/pyflakes/trunk/debian/patches/0.7.3-17-gecd6eca.patch
  packages/pyflakes/trunk/debian/patches/series
Modified:
  packages/pyflakes/trunk/debian/changelog
  packages/pyflakes/trunk/debian/control

Modified: packages/pyflakes/trunk/debian/changelog
===================================================================
--- packages/pyflakes/trunk/debian/changelog	2014-01-20 21:42:17 UTC (rev 10370)
+++ packages/pyflakes/trunk/debian/changelog	2014-01-20 23:00:06 UTC (rev 10371)
@@ -1,3 +1,10 @@
+pyflakes (0.7.3-2) UNRELEASED; urgency=medium
+
+  * Cherry-pick 17 upstream commits since 0.7.3, to add python 3.4
+    support.
+
+ -- Dimitri John Ledkov <xnox at ubuntu.com>  Mon, 20 Jan 2014 22:59:28 +0000
+
 pyflakes (0.7.3-1) unstable; urgency=low
 
   * Switch to dh-python.

Modified: packages/pyflakes/trunk/debian/control
===================================================================
--- packages/pyflakes/trunk/debian/control	2014-01-20 21:42:17 UTC (rev 10370)
+++ packages/pyflakes/trunk/debian/control	2014-01-20 23:00:06 UTC (rev 10371)
@@ -4,7 +4,7 @@
 Maintainer: Python Applications Packaging Team <python-apps-team at lists.alioth.debian.org>
 Uploaders: Tristan Seligmann <mithrandi at mithrandi.net>,
            Varun Hiremath <varun at debian.org>,
-           Dmitrijs Ledkovs <xnox at debian.org>,
+           Dimitri John Ledkov <xnox at debian.org>,
 Build-Depends: debhelper (>= 9),
 	       dh-python,
                python-all,

Added: packages/pyflakes/trunk/debian/patches/0.7.3-17-gecd6eca.patch
===================================================================
--- packages/pyflakes/trunk/debian/patches/0.7.3-17-gecd6eca.patch	                        (rev 0)
+++ packages/pyflakes/trunk/debian/patches/0.7.3-17-gecd6eca.patch	2014-01-20 23:00:06 UTC (rev 10371)
@@ -0,0 +1,277 @@
+--- a/LICENSE
++++ b/LICENSE
+@@ -1,5 +1,5 @@
+ Copyright 2005-2011 Divmod, Inc.
+-Copyright 2013 Florent Xicluna
++Copyright 2013-2014 Florent Xicluna
+ 
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+--- a/NEWS.txt
++++ b/NEWS.txt
+@@ -1,3 +1,9 @@
++UNRELEASED:
++  - Adapt for the AST in Python 3.4.
++  - Fix caret position on SyntaxError.
++  - Fix crash on Python 2.x with some doctest SyntaxError.
++  - Add tox.ini.
++
+ 0.7.3 (2013-07-02):
+   - Do not report undefined name for generator expression and dict or
+     set comprehension at class level.
+--- a/README.rst
++++ b/README.rst
+@@ -9,7 +9,7 @@
+ modules with side effects.  It's also much faster.
+ 
+ It is `available on PyPI <http://pypi.python.org/pypi/pyflakes>`_
+-and it supports all active versions of Python from 2.5 to 3.3.
++and it supports all active versions of Python from 2.5 to 3.4.
+ 
+ 
+ Installation
+--- a/pyflakes/checker.py
++++ b/pyflakes/checker.py
+@@ -7,12 +7,14 @@
+ import doctest
+ import os
+ import sys
+-try:
+-    builtin_vars = dir(__import__('builtins'))
+-    PY2 = False
+-except ImportError:
+-    builtin_vars = dir(__import__('__builtin__'))
++
++if sys.version_info < (3, 0):
+     PY2 = True
++    builtin_vars = dir(__import__('__builtin__'))
++else:
++    PY2 = False
++    builtin_vars = dir(__import__('builtins'))
++PY33 = sys.version_info < (3, 4)    # Python 2.5 to 3.3
+ 
+ try:
+     import ast
+@@ -578,7 +580,7 @@
+             except SyntaxError:
+                 e = sys.exc_info()[1]
+                 position = (node_lineno + example.lineno + e.lineno,
+-                            example.indent + 4 + e.offset)
++                            example.indent + 4 + (e.offset or 0))
+                 self.report(messages.DoctestSyntaxError, node, position)
+             else:
+                 self.offset = (node_offset[0] + node_lineno + example.lineno,
+@@ -599,7 +601,7 @@
+     # "expr" type nodes
+     BOOLOP = BINOP = UNARYOP = IFEXP = DICT = SET = YIELD = YIELDFROM = \
+         COMPARE = CALL = REPR = ATTRIBUTE = SUBSCRIPT = LIST = TUPLE = \
+-        STARRED = handleChildren
++        STARRED = NAMECONSTANT = handleChildren
+ 
+     NUM = STR = BYTES = ELLIPSIS = ignore
+ 
+@@ -705,6 +707,7 @@
+ 
+     def LAMBDA(self, node):
+         args = []
++        annotations = []
+ 
+         if PY2:
+             def addArgs(arglist):
+@@ -712,34 +715,41 @@
+                     if isinstance(arg, ast.Tuple):
+                         addArgs(arg.elts)
+                     else:
+-                        if arg.id in args:
+-                            self.report(messages.DuplicateArgument,
+-                                        node, arg.id)
+                         args.append(arg.id)
+             addArgs(node.args.args)
+             defaults = node.args.defaults
+         else:
+             for arg in node.args.args + node.args.kwonlyargs:
+-                if arg.arg in args:
+-                    self.report(messages.DuplicateArgument,
+-                                node, arg.arg)
+                 args.append(arg.arg)
+-                self.handleNode(arg.annotation, node)
+-            if hasattr(node, 'returns'):    # Only for FunctionDefs
+-                for annotation in (node.args.varargannotation,
+-                                   node.args.kwargannotation, node.returns):
+-                    self.handleNode(annotation, node)
++                annotations.append(arg.annotation)
+             defaults = node.args.defaults + node.args.kw_defaults
+ 
+-        # vararg/kwarg identifiers are not Name nodes
+-        for wildcard in (node.args.vararg, node.args.kwarg):
++        # Only for Python3 FunctionDefs
++        is_py3_func = hasattr(node, 'returns')
++
++        for arg_name in ('vararg', 'kwarg'):
++            wildcard = getattr(node.args, arg_name)
+             if not wildcard:
+                 continue
+-            if wildcard in args:
+-                self.report(messages.DuplicateArgument, node, wildcard)
+-            args.append(wildcard)
+-        for default in defaults:
+-            self.handleNode(default, node)
++            args.append(wildcard if PY33 else wildcard.arg)
++            if is_py3_func:
++                if PY33:  # Python 2.5 to 3.3
++                    argannotation = arg_name + 'annotation'
++                    annotations.append(getattr(node.args, argannotation))
++                else:     # Python >= 3.4
++                    annotations.append(wildcard.annotation)
++
++        if is_py3_func:
++            annotations.append(node.returns)
++
++        if len(set(args)) < len(args):
++            for (idx, arg) in enumerate(args):
++                if arg in args[:idx]:
++                    self.report(messages.DuplicateArgument, node, arg)
++
++        for child in annotations + defaults:
++            if child:
++                self.handleNode(child, node)
+ 
+         def runFunction():
+ 
+--- a/pyflakes/reporter.py
++++ b/pyflakes/reporter.py
+@@ -2,6 +2,7 @@
+ Provide the Reporter class.
+ """
+ 
++import re
+ import sys
+ 
+ 
+@@ -57,7 +58,8 @@
+         self._stderr.write(line)
+         self._stderr.write('\n')
+         if offset is not None:
+-            self._stderr.write(" " * (offset + 1) + "^\n")
++            self._stderr.write(re.sub(r'\S', ' ', line[:offset]) +
++                               "^\n")
+ 
+     def flake(self, message):
+         """
+--- a/pyflakes/test/test_api.py
++++ b/pyflakes/test/test_api.py
+@@ -163,7 +163,7 @@
+         self.assertEqual(
+             ("foo.py:3: a problem\n"
+              "bad line of source\n"
+-             "     ^\n"),
++             "    ^\n"),
+             err.getvalue())
+ 
+     def test_syntaxErrorNoOffset(self):
+@@ -197,7 +197,7 @@
+         self.assertEqual(
+             ("foo.py:3: a problem\n" +
+              lines[-1] + "\n" +
+-             "     ^\n"),
++             "    ^\n"),
+             err.getvalue())
+ 
+     def test_unexpectedError(self):
+@@ -322,7 +322,7 @@
+             ["""\
+ %s:8: invalid syntax
+     '''quux'''
+-           ^
++          ^
+ """ % (sourcePath,)])
+ 
+     def test_eofSyntaxError(self):
+@@ -336,7 +336,21 @@
+             ["""\
+ %s:1: unexpected EOF while parsing
+ def foo(
+-         ^
++        ^
++""" % (sourcePath,)])
++
++    def test_eofSyntaxErrorWithTab(self):
++        """
++        The error reported for source files which end prematurely causing a
++        syntax error reflects the cause for the syntax error.
++        """
++        sourcePath = self.makeTempFile("if True:\n\tfoo =")
++        self.assertHasErrors(
++            sourcePath,
++            ["""\
++%s:2: invalid syntax
++\tfoo =
++\t     ^
+ """ % (sourcePath,)])
+ 
+     def test_nonDefaultFollowsDefaultSyntaxError(self):
+@@ -350,7 +364,7 @@
+     pass
+ """
+         sourcePath = self.makeTempFile(source)
+-        last_line = '        ^\n' if sys.version_info >= (3, 2) else ''
++        last_line = '       ^\n' if sys.version_info >= (3, 2) else ''
+         self.assertHasErrors(
+             sourcePath,
+             ["""\
+@@ -368,7 +382,7 @@
+ foo(bar=baz, bax)
+ """
+         sourcePath = self.makeTempFile(source)
+-        last_line = '             ^\n' if sys.version_info >= (3, 2) else ''
++        last_line = '            ^\n' if sys.version_info >= (3, 2) else ''
+         self.assertHasErrors(
+             sourcePath,
+             ["""\
+@@ -386,7 +400,7 @@
+         if ver < (3,):
+             decoding_error = "%s: problem decoding source\n" % (sourcePath,)
+         else:
+-            last_line = '       ^\n' if ver >= (3, 2) else ''
++            last_line = '      ^\n' if ver >= (3, 2) else ''
+             # Column has been "fixed" since 3.2.4 and 3.3.1
+             col = 1 if ver >= (3, 3, 1) or ((3, 2, 4) <= ver < (3, 3)) else 2
+             decoding_error = """\
+--- a/pyflakes/test/test_doctests.py
++++ b/pyflakes/test/test_doctests.py
+@@ -207,3 +207,22 @@
+                     >>> Foo
+                 '''
+         """)
++
++    def test_noOffsetSyntaxErrorInDoctest(self):
++        exceptions = super(Test, self).flakes(
++            '''
++            def buildurl(base, *args, **kwargs):
++                """
++                >>> buildurl('/blah.php', ('a', '&'), ('b', '=')
++                '/blah.php?a=%26&b=%3D'
++                >>> buildurl('/blah.php', a='&', 'b'='=')
++                '/blah.php?b=%3D&a=%26'
++                """
++                pass
++            ''',
++            m.DoctestSyntaxError,
++            m.DoctestSyntaxError).messages
++        exc = exceptions[0]
++        self.assertEqual(exc.lineno, 4)
++        exc = exceptions[1]
++        self.assertEqual(exc.lineno, 6)
+--- /dev/null
++++ b/tox.ini
+@@ -0,0 +1,10 @@
++[tox]
++envlist =
++    py25,py26,py27,py32,py33,py34
++# pypy is not ready yet; run manually with tox -e pypy if you want to see
++# the failures
++
++[testenv]
++deps =
++commands =
++    python setup.py test -q

Added: packages/pyflakes/trunk/debian/patches/series
===================================================================
--- packages/pyflakes/trunk/debian/patches/series	                        (rev 0)
+++ packages/pyflakes/trunk/debian/patches/series	2014-01-20 23:00:06 UTC (rev 10371)
@@ -0,0 +1 @@
+0.7.3-17-gecd6eca.patch




More information about the Python-apps-commits mailing list