[arch-commits] Commit in python-sure/trunk (PKGBUILD py3k-fix.patch)

Felix Yan fyan at archlinux.org
Wed Apr 15 06:08:45 UTC 2015


    Date: Wednesday, April 15, 2015 @ 08:08:45
  Author: fyan
Revision: 131387

upgpkg: python-sure 1.2.10-1

Added:
  python-sure/trunk/py3k-fix.patch
Modified:
  python-sure/trunk/PKGBUILD

----------------+
 PKGBUILD       |   15 +++++++----
 py3k-fix.patch |   74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 84 insertions(+), 5 deletions(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2015-04-15 06:01:34 UTC (rev 131386)
+++ PKGBUILD	2015-04-15 06:08:45 UTC (rev 131387)
@@ -1,9 +1,9 @@
 # $Id$
-# Maintainer: Felix Yan <felixonmars at gmail.com>
+# Maintainer: Felix Yan <felixonmars at archlinux.org>
 
 pkgbase=python-sure
 pkgname=("python-sure" "python2-sure")
-pkgver=1.2.7
+pkgver=1.2.10
 pkgrel=1
 pkgdesc="HTTP client mock for Python"
 arch=('any')
@@ -11,11 +11,16 @@
 license=('GPL')
 makedepends=('python-six' 'python2-six' 'python-mock' 'python2-mock')
 checkdepends=('python-nose' 'python2-nose')
-source=("https://pypi.python.org/packages/source/s/sure/sure-$pkgver.tar.gz")
-sha512sums=('408d7334c3b989e29f757a31e137cfda6ccc3b4e03ed0a38bc7d72a23ff3ced11e1112b5d2597e20653c034330ec69ec9e713787516283e71ca404b1b1e770e1')
+source=("https://pypi.python.org/packages/source/s/sure/sure-$pkgver.tar.gz"
+        py3k-fix.patch)
+sha512sums=('9053cd493a26a9314db7e5967dd8ce8caebd110ba9b26ea077f5dc8d9d34ff7d7feb7bde9886420cd64d11e88574b44396fddbaaeaafc380244f2d48d59185d4'
+            '90118b3c3148b6dd6904f94199fc7ae98fc805980132000e270e1b80a563620a1216f916e82c894cfe8cd0c68041ca091ebd7c0a8e64b1cf6dd3c84db3b0d558')
 
 prepare() {
-  cp -r "sure-$pkgver"{,-py2}
+  cp -a "sure-$pkgver"{,-py2}
+
+  cd sure-$pkgver
+  patch -p1 -i ../py3k-fix.patch
 }
 
 check() {

Added: py3k-fix.patch
===================================================================
--- py3k-fix.patch	                        (rev 0)
+++ py3k-fix.patch	2015-04-15 06:08:45 UTC (rev 131387)
@@ -0,0 +1,74 @@
+From dfa565626a53c8902a7f108417281c95f8e1f241 Mon Sep 17 00:00:00 2001
+From: Timo Furrer <tuxtimo at gmail.com>
+Date: Thu, 11 Dec 2014 10:45:50 +0100
+Subject: [PATCH] make python 3 compatible again The function objects in python
+ 3 have no `func_code` member anymore. Use `__code__` instead. The byte
+ objects in python 3 have no `format` method. Use `encode` instead. The
+ representation of the strings and encoded strings are different in python 2
+ and python 3 thus use PY3 from six. Remove unlucky example from README since
+ python 3 returns a float and python 2 an int in this situation Python 2 and 3
+ build is working again
+
+---
+ README.md                       |  1 -
+ sure/old.py                     |  8 ++++----
+ tests/test_assertion_builder.py | 10 ++++++++--
+ 3 files changed, 12 insertions(+), 7 deletions(-)
+
+diff --git a/README.md b/README.md
+index 03d7e2f..5e09d57 100644
+--- a/README.md
++++ b/README.md
+@@ -32,7 +32,6 @@ import sure
+ 
+ (4).should.be.equal(2 + 2)
+ (7.5).should.eql(3.5 + 4)
+-(2).should.equal(8 / 4)
+ 
+ (3).shouldnt.be.equal(5)
+ ```
+diff --git a/sure/old.py b/sure/old.py
+index 70822e1..13a3f74 100644
+--- a/sure/old.py
++++ b/sure/old.py
+@@ -42,10 +42,10 @@
+ 
+ 
+ def identify_callable_location(callable_object):
+-    filename = os.path.relpath(callable_object.func_code.co_filename)
+-    lineno = callable_object.func_code.co_firstlineno
+-    callable_name = callable_object.func_code.co_name
+-    return b'{0} [{1} line {2}]'.format(callable_name, filename, lineno)
++    filename = os.path.relpath(callable_object.__code__.co_filename)
++    lineno = callable_object.__code__.co_firstlineno
++    callable_name = callable_object.__code__.co_name
++    return '{0} [{1} line {2}]'.format(callable_name, filename, lineno).encode()
+ 
+ 
+ def is_iterable(obj):
+diff --git a/tests/test_assertion_builder.py b/tests/test_assertion_builder.py
+index 6a58c1a..5b3d2de 100644
+--- a/tests/test_assertion_builder.py
++++ b/tests/test_assertion_builder.py
+@@ -648,13 +648,19 @@ def blah(num):
+         raise RuntimeError('should not have reached here')
+ 
+     except AssertionError as e:
+-        expect(str(e)).to.equal("When calling 'blah [tests/test_assertion_builder.py line 633]' the exception message does not match. Expected to match regex: u'invalid regex'\n against:\n u'this message'")
++        if PY3:
++            expect(str(e)).to.equal("When calling b'blah [tests/test_assertion_builder.py line 633]' the exception message does not match. Expected to match regex: 'invalid regex'\n against:\n 'this message'")
++        else:
++            expect(str(e)).to.equal("When calling 'blah [tests/test_assertion_builder.py line 633]' the exception message does not match. Expected to match regex: u'invalid regex'\n against:\n u'this message'")
+ 
+     try:
+         expect(blah).when.called_with(1).should.throw(ValueError, re.compile(r'invalid regex'))
+         raise RuntimeError('should not have reached here')
+     except AssertionError as e:
+-        expect(str(e)).to.equal("When calling 'blah [tests/test_assertion_builder.py line 633]' the exception message does not match. Expected to match regex: u'invalid regex'\n against:\n u'this message'")
++        if PY3:
++            expect(str(e)).to.equal("When calling b'blah [tests/test_assertion_builder.py line 633]' the exception message does not match. Expected to match regex: 'invalid regex'\n against:\n 'this message'")
++        else:
++            expect(str(e)).to.equal("When calling 'blah [tests/test_assertion_builder.py line 633]' the exception message does not match. Expected to match regex: u'invalid regex'\n against:\n u'this message'")
+ 
+ def test_should_not_be_different():
+     ("'something'.should_not.be.different('SOMETHING'.lower())")



More information about the arch-commits mailing list