Fix tests with python3.4.
authorMike Gilbert <floppym@gentoo.org>
Mon, 1 Dec 2014 15:39:16 +0000 (15:39 +0000)
committerMike Gilbert <floppym@gentoo.org>
Mon, 1 Dec 2014 15:39:16 +0000 (15:39 +0000)
Package-Manager: portage-2.2.14/cvs/Linux x86_64
Manifest-Sign-Key: 0x0BBEEA1FEA4843A4

dev-python/python-ptrace/ChangeLog
dev-python/python-ptrace/Manifest
dev-python/python-ptrace/files/0.8.1-python3.4.patch [new file with mode: 0644]
dev-python/python-ptrace/python-ptrace-0.8.1-r1.ebuild [moved from dev-python/python-ptrace/python-ptrace-0.8.1.ebuild with 76% similarity]

index 9a4d3ea406c97d7dee01e0e925dabb3cf329647a..77151411b7bd050a269345e10d27efd5ee49bdc9 100644 (file)
@@ -1,6 +1,12 @@
 # ChangeLog for dev-python/python-ptrace
 # Copyright 1999-2014 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/dev-python/python-ptrace/ChangeLog,v 1.19 2014/12/01 02:16:04 floppym Exp $
+# $Header: /var/cvsroot/gentoo-x86/dev-python/python-ptrace/ChangeLog,v 1.20 2014/12/01 15:39:15 floppym Exp $
+
+*python-ptrace-0.8.1-r1 (01 Dec 2014)
+
+  01 Dec 2014; Mike Gilbert <floppym@gentoo.org> +files/0.8.1-python3.4.patch,
+  +python-ptrace-0.8.1-r1.ebuild, -python-ptrace-0.8.1.ebuild:
+  Fix tests with python3.4.
 
   01 Dec 2014; Mike Gilbert <floppym@gentoo.org> python-ptrace-0.8.1.ebuild:
   Add upstream bug url.
index 57904981d710b9aff3401bfa4a98abada5d3ac8f..6bdf641b85b6fcb0d5d014ae96a6b83a7e8e0a5e 100644 (file)
@@ -1,14 +1,15 @@
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA256
 
+AUX 0.8.1-python3.4.patch 4629 SHA256 3bb83e7303a412854912091394cc29a6a8acf3486b3008bac14669b744e81245 SHA512 3b5c072b55c138c97e9b6456354bdf17c820d448880e0d6bb5ce398b7dfd1bd432f9886da4f8b960578f60e24fb636142bdaa66566ac22e12cda0928753aa46e WHIRLPOOL a8aeaf886a02264170e84b97fbcc6291f8ca09e59dff9d8894debd69a916cf267044ddf527bd7c94cc7c89b7c00fe0fa557d8ff62e2e4ddaf636fb75978f9b86
 DIST python-ptrace-0.8.1.tar.gz 93674 SHA256 779e04c7bdc00150b739e7d49c9c61b7f36f17afd26355f91b10cd0e7d55d19f SHA512 1c3dadf381ad0fe30374fe030fc3a81b5ec0885c31ac9be4ae561cf14ff891fc2e465555133b2efce6be0154b06768121aa068161bb3de10aca6df0eb181e25c WHIRLPOOL 1541571ed580b5852b1fc51f515776463dc622a4a2c334691f0433083a29bc1059549e0b4e938ea7c694517e341cd39bbc3f487f5ea7f83b327aaad1dbd8b7df
-EBUILD python-ptrace-0.8.1.ebuild 1133 SHA256 c1c1ea2fcff5e04c0e1a1ec2a49e0ff0bda20c19505cb390acecbcff16a4dd25 SHA512 c6f8f2bdb1d71ed8d1ab89f1f60689bbcab256e0ec39e918ec899df4b6519e6d7b9b72fab8c744dc72a47d1b3406e2756407c2abfbd8ecc29e29b8ee3c8c4362 WHIRLPOOL 42039c8c5c9619a08d19e8366d38565d258eef953a8756aeea727d1a45e9aa3097f3b997a78db579528c2c94809ab56d4522c70dba2a9ca3a26b6b1f2771e238
-MISC ChangeLog 3331 SHA256 a61c0acd5794caab42cc2186df69e7d4f266c1ae8292633c49d4ca93b46c1ee5 SHA512 46fe2cc8377b0b215f09057a19689ad96d3dadb6a480b2dd0fbfe8712ba8a5103421e310b2a4de03f8617171fdc7685441850aa1e1617ab9206d3918d0567787 WHIRLPOOL 03348e29303375387bba3b3f553ffc2d0d166b6fc67ca0fda6ba2e3e542c14b3394fc15f6c46be0a213130ea19b6b401aede6b8c686e83fa68d88f9dbb0801b9
+EBUILD python-ptrace-0.8.1-r1.ebuild 977 SHA256 db7d95149c201d86d23caad4386c2f67b5ac95f4611133d914d4d021dd6e1f7b SHA512 4080044f801bc4c2352b00e0c5966cf1297fb805ba2c4a8bb5addc24510f4a74dd7e636ef9c05d010d4711fec198f6132faee08635586d04a2faff0cb49fad72 WHIRLPOOL ea77aaca3cfa3884de4078a1e74fe4220d99c1b9228fff88016c7ee2235822dddca192a54a5c77b2597333cf64672da7db6a4ccaa9ef90ef688279ffdea568e9
+MISC ChangeLog 3541 SHA256 41f730b3950ad04ee5e6c4c22efe21a1700ec738dcdab0268310f440f0daf219 SHA512 0b001b3b53f33afa87cb3b78be521982ddc3484b5207a1df8f44692ac152e9a357978d582f484153a97448e5996fa3626a0b36a4ef2be96a805f96c40294835c WHIRLPOOL 2cb1aeab75c9c849a8f1c05a8ce177d564b5ebcc3d69c662a15ad244c995fe5fccfc222bae287cd043d85cef3ce8d076097a35991f184e0ff7bca255a3d8ab4f
 MISC metadata.xml 236 SHA256 ef9f12fc623783043709c89a6c5febf6f6d6bcec5882e7ce867228e3e13f0b40 SHA512 6ab6dc105ead9eb542ce5800527ccf9fe99f813cfe59ca8b075b877468d2f027ce6e96ddbe1cfc4e9ac42fc24a96a80b5490e5e2e85eb3d8145e4b97c2a2dcec WHIRLPOOL f0b5d1dee36e29c2ef1122261d24054db7388f32b2e743e47177156f396cf24e77d88af071e93f3505946e5026ae4696e71949e0163da0f498e4d55c0243e2e8
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
-iF4EAREIAAYFAlR7z2UACgkQC77qH+pIQ6TnsAEAke1HfmWUs4pC5A1iS9UdVCmR
-LhkknNAqGuIDDkByZTkA/R6w0KOXoqHQeFCXJXYBtcbQO6gn3kgxhR5HC8dfaahf
-=Hygo
+iF4EAREIAAYFAlR8i6QACgkQC77qH+pIQ6Q0FgD+LZo/+O/t5u2uCpbUUfd64fwY
+F3z80PkV7rVllmH+JhkA+gKi8gH8cpgZxaDAfkBm4HUgOCeWa4OVvrd/8MJZaBDG
+=r45V
 -----END PGP SIGNATURE-----
diff --git a/dev-python/python-ptrace/files/0.8.1-python3.4.patch b/dev-python/python-ptrace/files/0.8.1-python3.4.patch
new file mode 100644 (file)
index 0000000..2e6e76f
--- /dev/null
@@ -0,0 +1,147 @@
+# HG changeset patch
+# User Victor Stinner <victor.stinner@gmail.com>
+# Date 1417423044 -3600
+#      Mon Dec 01 09:37:24 2014 +0100
+# Node ID eba1a6dba205559d724d32c80d955a65e078505e
+# Parent  e6fef4231a8a28ef91c1feaf3bfbcbd29822c939
+Issue #17: syscall parser now supports O_CLOEXEC and SOCK_CLOEXEC, fix unit
+tests on Python 3.4 and newer
+
+diff --git a/doc/changelog.rst b/doc/changelog.rst
+--- a/doc/changelog.rst
++++ b/doc/changelog.rst
+@@ -3,6 +3,12 @@
+ Changelog
+ =========
+ 
++python-ptrace 0.8.2
++-------------------
++
++* Issue #17: syscall parser now supports O_CLOEXEC and SOCK_CLOEXEC, fix unit
++  tests on Python 3.4 and newer
++
+ python-ptrace 0.8.1 (2014-10-30)
+ --------------------------------
+ 
+diff --git a/ptrace/syscall/posix_arg.py b/ptrace/syscall/posix_arg.py
+--- a/ptrace/syscall/posix_arg.py
++++ b/ptrace/syscall/posix_arg.py
+@@ -24,7 +24,7 @@
+     return formatBits(argument.value, ACCESS_MODE_BITMASK, "F_OK")
+ 
+ # From /usr/include/bits/fcntl.h (Ubuntu Feisty, i386)
+-OPEN_MODE_BITMASK = (
++OPEN_MODE_BITMASK = [
+     (0o1, "O_WRONLY"),
+     (0o2, "O_RDWR"),
+     (0o100, "O_CREAT"),
+@@ -40,10 +40,17 @@
+     (0o200000, "O_DIRECTORY"),
+     (0o400000, "O_NOFOLLOW"),
+     (0o1000000, "O_NOATIME"),
+-)
++]
++O_CLOEXEC = 0o02000000
+ 
+ def formatOpenMode(argument):
+-    return formatBits(int(argument.value), OPEN_MODE_BITMASK, "O_RDONLY", oct)
++    value = argument.value
++    cloexec = bool(value & O_CLOEXEC)
++    value = value & ~O_CLOEXEC
++    text = formatBits(int(value), OPEN_MODE_BITMASK, "O_RDONLY", oct)
++    if cloexec:
++        text += '|O_CLOEXEC'
++    return text
+ 
+ CLONE_FLAGS_BITMASK = (
+     (0x00000100, "CLONE_VM"),
+diff --git a/ptrace/syscall/posix_constants.py b/ptrace/syscall/posix_constants.py
+--- a/ptrace/syscall/posix_constants.py
++++ b/ptrace/syscall/posix_constants.py
+@@ -1,5 +1,5 @@
+ from ptrace.syscall.socketcall_constants import (
+-    SOCKET_FAMILY, SOCKET_TYPE, SOCKET_PROTOCOL,
++    SOCKET_FAMILY, SOCKET_PROTOCOL,
+     SETSOCKOPT_LEVEL, SETSOCKOPT_OPTNAME)
+ 
+ SYSCALL_ARG_DICT = {
+@@ -51,7 +51,6 @@
+     },
+     "socket": {
+         "domain": SOCKET_FAMILY,
+-        "type": SOCKET_TYPE,
+         "protocol": SOCKET_PROTOCOL,
+     },
+     "getsockopt": {
+diff --git a/ptrace/syscall/socketcall_constants.py b/ptrace/syscall/socketcall_constants.py
+--- a/ptrace/syscall/socketcall_constants.py
++++ b/ptrace/syscall/socketcall_constants.py
+@@ -1,3 +1,5 @@
++import socket
++
+ SOCKETCALL = {
+     1: "socket",
+     2: "bind",
+@@ -56,6 +58,19 @@
+     10: "SOCK_PACKET",
+ }
+ 
++def formatSocketType(argument):
++    value = argument.value
++    text = []
++    if hasattr(socket, 'SOCK_CLOEXEC'):
++        cloexec = value & socket.SOCK_CLOEXEC
++        value &= ~socket.SOCK_CLOEXEC
++    else:
++        cloexec = False
++    text = SOCKET_TYPE.get(value, value)
++    if cloexec:
++        text += '|SOCK_CLOEXEC'
++    return text
++
+ SOCKET_PROTOCOL = {
+      1: "IPPROTO_ICMP",
+     58: "IPPROTO_ICMPV6",
+diff --git a/ptrace/syscall/syscall_argument.py b/ptrace/syscall/syscall_argument.py
+--- a/ptrace/syscall/syscall_argument.py
++++ b/ptrace/syscall/syscall_argument.py
+@@ -22,6 +22,7 @@
+     from ptrace.syscall.freebsd_constants import SYSCALL_ARG_DICT
+ else:
+     SYSCALL_ARG_DICT = {}
++from ptrace.syscall.socketcall_constants import formatSocketType
+ 
+ KNOWN_STRUCTS = []
+ if RUNNING_LINUX:
+@@ -35,6 +36,7 @@
+     "mmap": {"prot": formatMmapProt},
+     "mmap2": {"prot": formatMmapProt},
+     "clone": {"flags": formatCloneFlags},
++    "socket": {"type": formatSocketType},
+     "setsockopt": {"optval": formatOptVal},
+ }
+ 
+diff --git a/tests/test_strace.py b/tests/test_strace.py
+--- a/tests/test_strace.py
++++ b/tests/test_strace.py
+@@ -39,10 +39,19 @@
+             expected = os.fsencode(expected)
+         self.assertEqual(match.group(1), expected)
+ 
++    def test_open(self):
++        if PY3:
++            code = 'open(%a).close()' % __file__
++        else:
++            code = 'open(%r).close()' % __file__
++        stdout = self.strace(sys.executable, '-c', code)
++        pattern = re.compile(br"^open\(.*test_strace\.py', O_RDONLY(\|O_CLOEXEC)?\)", re.MULTILINE)
++        self.assertTrue(pattern.search(stdout), stdout)
++
+     def test_socket(self):
+         code = 'import socket; socket.socket(socket.AF_INET, socket.SOCK_STREAM).close()'
+         stdout = self.strace(sys.executable, '-c', code)
+-        pattern = re.compile(b'^socket\\(AF_INET, SOCK_STREAM, ', re.MULTILINE)
++        pattern = re.compile(br'^socket\(AF_INET, SOCK_STREAM(\|SOCK_CLOEXEC)?, ', re.MULTILINE)
+         self.assertTrue(pattern.search(stdout), stdout)
+ 
+ if __name__ == "__main__":
similarity index 76%
rename from dev-python/python-ptrace/python-ptrace-0.8.1.ebuild
rename to dev-python/python-ptrace/python-ptrace-0.8.1-r1.ebuild
index 95fc1580fc69396085d26ac0de3709c7e1c74a9f..383b298a7c2238fb435d76e6cee69c43e39e20e2 100644 (file)
@@ -1,6 +1,6 @@
 # Copyright 1999-2014 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/dev-python/python-ptrace/python-ptrace-0.8.1.ebuild,v 1.4 2014/12/01 02:16:04 floppym Exp $
+# $Header: /var/cvsroot/gentoo-x86/dev-python/python-ptrace/python-ptrace-0.8.1-r1.ebuild,v 1.1 2014/12/01 15:39:15 floppym Exp $
 
 EAPI=5
 PYTHON_COMPAT=( python{2_7,3_3,3_4} pypy )
@@ -16,10 +16,9 @@ SLOT="0"
 KEYWORDS="~amd64 ~x86"
 IUSE="doc examples"
 
+PATCHES=( "${FILESDIR}/0.8.1-python3.4.patch" )
+
 python_test() {
-       # Python 3.4 adds SOCK_CLOEXEC to socket.type automatically, and ptrace does
-       # not translate that on output causing it to fail test_strace.test_socket.
-       # https://bitbucket.org/haypo/python-ptrace/issue/17
        "${PYTHON}" runtests.py || die "Testing failed with ${EPYTHON}"
 }