[arch-commits] Commit in python-astroid/trunk (PKGBUILD python-3.4.patch)

Felix Yan fyan at nymeria.archlinux.org
Sat Mar 22 16:55:18 UTC 2014


    Date: Saturday, March 22, 2014 @ 17:55:18
  Author: fyan
Revision: 208334

upgpkg: python-astroid 1.0.1-3

- fix FS#39585

Added:
  python-astroid/trunk/python-3.4.patch
Modified:
  python-astroid/trunk/PKGBUILD

------------------+
 PKGBUILD         |   18 ++++++---
 python-3.4.patch |  104 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 117 insertions(+), 5 deletions(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2014-03-22 16:03:52 UTC (rev 208333)
+++ PKGBUILD	2014-03-22 16:55:18 UTC (rev 208334)
@@ -4,20 +4,28 @@
 pkgbase=python-astroid
 pkgname=('python2-astroid' 'python-astroid')
 pkgver=1.0.1
-pkgrel=2
+pkgrel=3
 pkgdesc="Useful miscellaneous modules used by Logilab projects"
 arch=('any')
 url="http://www.logilab.org/project/logilab-common"
 license=('LGPL')
 makedepends=('python2' 'python')
-source=(https://pypi.python.org/packages/source/a/astroid/astroid-${pkgver}.tar.gz)
-sha1sums=('4b0080576174cc0a3519a6c6e9025a8ee853956a')
+source=(https://pypi.python.org/packages/source/a/astroid/astroid-${pkgver}.tar.gz
+        python-3.4.patch)
+sha1sums=('4b0080576174cc0a3519a6c6e9025a8ee853956a'
+          '8d4f2f76f5b0c90ad508c5fded85d37bbbe9e15a')
 
+prepare() {
+  cp -a astroid-${pkgver}{,-py3}
+
+  cd astroid-${pkgver}-py3
+  # FS#39585
+  patch -p1 -i "$srcdir/python-3.4.patch"
+}
+
 build() {
   cd "${srcdir}"
 
-  cp -a astroid-${pkgver}{,-py3}
-
   cd astroid-${pkgver}
   python2 setup.py build
 

Added: python-3.4.patch
===================================================================
--- python-3.4.patch	                        (rev 0)
+++ python-3.4.patch	2014-03-22 16:55:18 UTC (rev 208334)
@@ -0,0 +1,104 @@
+diff --git a/rebuilder.py b/rebuilder.py
+--- a/rebuilder.py
++++ b/rebuilder.py
+@@ -88,6 +88,8 @@
+             'Repr': 'Backquote',
+             }
+
++PY34 = sys.version_info >= (3, 4)
++
+ def _init_set_doc(node, newnode):
+     newnode.doc = None
+     try:
+@@ -187,13 +188,20 @@
+         newnode.defaults = [self.visit(child, newnode) for child in node.defaults]
+         newnode.kwonlyargs = []
+         newnode.kw_defaults = []
+-        newnode.vararg = node.vararg
+-        newnode.kwarg = node.kwarg
++        vararg, kwarg = node.vararg, node.kwarg
++        # change added in 82732 (7c5c678e4164), vararg and kwarg
++        # are instances of `_ast.arg`, not strings
++        if vararg and PY34:
++            vararg = vararg.arg
++        if kwarg and PY34:
++            kwarg = kwarg.arg
++        newnode.vararg = vararg
++        newnode.kwarg = kwarg
+         # save argument names in locals:
+-        if node.vararg:
+-            newnode.parent.set_local(newnode.vararg, newnode)
+-        if node.kwarg:
+-            newnode.parent.set_local(newnode.kwarg, newnode)
++        if vararg:
++            newnode.parent.set_local(vararg, newnode)
++        if kwarg:
++            newnode.parent.set_local(kwarg, newnode)
+         newnode.set_line_info(newnode.last_child())
+         return newnode
+ 
+@@ -838,6 +846,12 @@
+         # XXX or we should instead introduce a Arg node in astroid ?
+         return self.visit_assname(node, parent, node.arg)
+ 
++    def visit_nameconstant(self, node, parent):
++        # in Python 3.4 we have NameConstant for True / False / None
++        newnode = new.Const(node.value)
++        _set_infos(node, newnode, parent)
++        return newnode
++
+     def visit_arguments(self, node, parent):
+         newnode = super(TreeRebuilder3k, self).visit_arguments(node, parent)
+         self.asscontext = "Ass"
+diff --git a/test/unittest_inference.py b/test/unittest_inference.py
+--- a/test/unittest_inference.py
++++ b/test/unittest_inference.py
+@@ -52,6 +52,11 @@
+ else:
+     EXC_MODULE = BUILTINS
+ 
++if sys.version_info < (3, 4):
++    SITE = 'site'
++else:
++    SITE = '_sitebuiltins'
++
+ class InferenceTC(TestCase):
+ 
+     CODE = '''
+@@ -700,7 +705,7 @@
+         self.assertEqual(len(infered), 1, infered)
+         self.assertIsInstance(infered[0], Instance)
+         self.assertEqual(str(infered[0]),
+-                             'Instance of site._Helper')
++                             'Instance of %s._Helper' % SITE)
+ 
+     def test_builtin_open(self):
+         code = '''
+diff --git a/test/unittest_regrtest.py b/test/unittest_regrtest.py
+--- a/test/unittest_regrtest.py
++++ b/test/unittest_regrtest.py
+@@ -16,7 +16,7 @@
+ # You should have received a copy of the GNU Lesser General Public License along
+ # with astroid. If not, see <http://www.gnu.org/licenses/>.
+ 
+-from logilab.common.testlib import unittest_main, TestCase
++from logilab.common.testlib import unittest_main, TestCase, require_version
+ 
+ from astroid import ResolveError, MANAGER, Instance, nodes, YES, InferenceError
+ from astroid.builder import AstroidBuilder
+@@ -135,6 +135,15 @@
+         self.assertEqual(len(infered), 1)
+         self.assertIsInstance(infered[0], Instance)
+ 
++    @require_version('3.0')
++    def test_nameconstant(self):
++        # used to fail for Python 3.4
++        builder = AstroidBuilder()
++        astroid = builder.string_build("def test(x=True): pass")
++        default = astroid.body[0].args.args[0]
++        self.assertEqual(default.name, 'x')
++        self.assertEqual(next(default.infer()).value, True)
++
+ 
+ class Whatever(object):
+     a = property(lambda x: x, lambda x: x)




More information about the arch-commits mailing list