aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJung-uk Kim <jkim@FreeBSD.org>2010-07-19 21:59:28 +0000
committerJung-uk Kim <jkim@FreeBSD.org>2010-07-19 21:59:28 +0000
commit5045cff4a059fb43d185e75ed1258eb9fbe4ca4b (patch)
tree20aff63270becd83fe367054a3d8fadbd2f72db4
parent0b562433c13e3bfce38e1d374ed3efd63a3614e7 (diff)
downloadports-5045cff4a059fb43d185e75ed1258eb9fbe4ca4b.tar.gz
ports-5045cff4a059fb43d185e75ed1258eb9fbe4ca4b.zip
Fix fcntl module to accept 'unsigned long' type commands for ioctl(2).
Although POSIX says the type is 'int', all BSD variants (including Mac OS X) have been using 'unsigned long' type for very long time and its use predates the standard long enough. For certain commands (e.g., TIOCSWINSZ, FIONBIO), the Python value may get sign-extended on 64-bit platforms (by implicit type promotion) and it causes annoying warnings from kernel such as this: WARNING pid 24509 (python2.6): ioctl sign-extension ioctl ffffffff8004667e Approved by: python (maintainer timeout)
Notes
Notes: svn path=/head/; revision=257978
-rw-r--r--lang/python24/Makefile2
-rw-r--r--lang/python24/files/patch-Modules-fcntlmodule.c38
-rw-r--r--lang/python25/Makefile1
-rw-r--r--lang/python25/files/patch-Lib-test-test_ioctl.py27
-rw-r--r--lang/python25/files/patch-Modules-fcntlmodule.c53
-rw-r--r--lang/python26/Makefile1
-rw-r--r--lang/python26/files/patch-Doc-library-fcntl.rst11
-rw-r--r--lang/python26/files/patch-Lib-test-test_ioctl.py23
-rw-r--r--lang/python26/files/patch-Modules-fcntlmodule.c53
-rw-r--r--lang/python31/Makefile1
-rw-r--r--lang/python31/files/patch-Doc-library-fcntl.rst11
-rw-r--r--lang/python31/files/patch-Lib-test-test_fcntl.py11
-rw-r--r--lang/python31/files/patch-Lib-test-test_ioctl.py23
-rw-r--r--lang/python31/files/patch-Lib-test-test_socket.py11
-rw-r--r--lang/python31/files/patch-Modules-fcntlmodule.c53
-rw-r--r--lang/python32/Makefile1
-rw-r--r--lang/python32/files/patch-Doc-library-fcntl.rst11
-rw-r--r--lang/python32/files/patch-Lib-test-test_fcntl.py11
-rw-r--r--lang/python32/files/patch-Lib-test-test_ioctl.py23
-rw-r--r--lang/python32/files/patch-Lib-test-test_socket.py11
-rw-r--r--lang/python32/files/patch-Modules-fcntlmodule.c53
21 files changed, 428 insertions, 1 deletions
diff --git a/lang/python24/Makefile b/lang/python24/Makefile
index 5e106c45a188..628d1fde5451 100644
--- a/lang/python24/Makefile
+++ b/lang/python24/Makefile
@@ -7,7 +7,7 @@
PORTNAME= python24
PORTVERSION= 2.4.5
-PORTREVISION= 5
+PORTREVISION= 6
CATEGORIES= lang python ipv6
MASTER_SITES= ${PYTHON_MASTER_SITES}
MASTER_SITE_SUBDIR= ${PYTHON_MASTER_SITE_SUBDIR}
diff --git a/lang/python24/files/patch-Modules-fcntlmodule.c b/lang/python24/files/patch-Modules-fcntlmodule.c
new file mode 100644
index 000000000000..e675a6be06b6
--- /dev/null
+++ b/lang/python24/files/patch-Modules-fcntlmodule.c
@@ -0,0 +1,38 @@
+--- Modules/fcntlmodule.c.orig 2006-09-27 15:17:32.000000000 -0400
++++ Modules/fcntlmodule.c 2010-06-24 21:15:48.000000000 -0400
+@@ -95,7 +95,7 @@
+ {
+ #define IOCTL_BUFSZ 1024
+ int fd;
+- int code;
++ unsigned long code;
+ int arg;
+ int ret;
+ char *str;
+@@ -103,7 +103,7 @@
+ int mutate_arg = 0;
+ char buf[IOCTL_BUFSZ+1]; /* argument plus NUL byte */
+
+- if (PyArg_ParseTuple(args, "O&iw#|i:ioctl",
++ if (PyArg_ParseTuple(args, "O&kw#|i:ioctl",
+ conv_descriptor, &fd, &code,
+ &str, &len, &mutate_arg)) {
+ char *arg;
+@@ -164,7 +164,7 @@
+ }
+
+ PyErr_Clear();
+- if (PyArg_ParseTuple(args, "O&is#:ioctl",
++ if (PyArg_ParseTuple(args, "O&ks#:ioctl",
+ conv_descriptor, &fd, &code, &str, &len)) {
+ if (len > IOCTL_BUFSZ) {
+ PyErr_SetString(PyExc_ValueError,
+@@ -186,7 +186,7 @@
+ PyErr_Clear();
+ arg = 0;
+ if (!PyArg_ParseTuple(args,
+- "O&i|i;ioctl requires a file or file descriptor,"
++ "O&k|i;ioctl requires a file or file descriptor,"
+ " an integer and optionally a integer or buffer argument",
+ conv_descriptor, &fd, &code, &arg)) {
+ return NULL;
diff --git a/lang/python25/Makefile b/lang/python25/Makefile
index 3f647bc78182..6096791061aa 100644
--- a/lang/python25/Makefile
+++ b/lang/python25/Makefile
@@ -6,6 +6,7 @@
PORTNAME= python25
PORTVERSION= 2.5.5
+PORTREVISION= 1
CATEGORIES= lang python ipv6
MASTER_SITES= ${PYTHON_MASTER_SITES}
MASTER_SITE_SUBDIR= ${PYTHON_MASTER_SITE_SUBDIR}
diff --git a/lang/python25/files/patch-Lib-test-test_ioctl.py b/lang/python25/files/patch-Lib-test-test_ioctl.py
new file mode 100644
index 000000000000..b354e097c21a
--- /dev/null
+++ b/lang/python25/files/patch-Lib-test-test_ioctl.py
@@ -0,0 +1,27 @@
+--- Lib/test/test_ioctl.py.orig 2008-08-03 20:45:34.000000000 -0400
++++ Lib/test/test_ioctl.py 2010-06-24 13:26:52.000000000 -0400
+@@ -44,21 +44,12 @@ class IoctlTests(unittest.TestCase):
+ raise TestSkipped('pty module required')
+ mfd, sfd = pty.openpty()
+ try:
+- if termios.TIOCSWINSZ < 0:
+- set_winsz_opcode_maybe_neg = termios.TIOCSWINSZ
+- set_winsz_opcode_pos = termios.TIOCSWINSZ & 0xffffffffL
+- else:
+- set_winsz_opcode_pos = termios.TIOCSWINSZ
+- set_winsz_opcode_maybe_neg, = struct.unpack("i",
+- struct.pack("I", termios.TIOCSWINSZ))
+-
++ set_winsz_opcode = termios.TIOCSWINSZ
+ # We're just testing that these calls do not raise exceptions.
+ saved_winsz = fcntl.ioctl(mfd, termios.TIOCGWINSZ, "\0"*8)
+ our_winsz = struct.pack("HHHH",80,25,0,0)
+- # test both with a positive and potentially negative ioctl code
+- new_winsz = fcntl.ioctl(mfd, set_winsz_opcode_pos, our_winsz)
+- new_winsz = fcntl.ioctl(mfd, set_winsz_opcode_maybe_neg, our_winsz)
+- fcntl.ioctl(mfd, set_winsz_opcode_maybe_neg, saved_winsz)
++ new_winsz = fcntl.ioctl(mfd, set_winsz_opcode, our_winsz)
++ fcntl.ioctl(mfd, set_winsz_opcode, saved_winsz)
+ finally:
+ os.close(mfd)
+ os.close(sfd)
diff --git a/lang/python25/files/patch-Modules-fcntlmodule.c b/lang/python25/files/patch-Modules-fcntlmodule.c
new file mode 100644
index 000000000000..6a3d1dfe5240
--- /dev/null
+++ b/lang/python25/files/patch-Modules-fcntlmodule.c
@@ -0,0 +1,53 @@
+--- Modules/fcntlmodule.c.orig 2008-08-03 20:45:34.000000000 -0400
++++ Modules/fcntlmodule.c 2010-06-24 22:22:33.000000000 -0400
+@@ -97,20 +97,15 @@
+ {
+ #define IOCTL_BUFSZ 1024
+ int fd;
+- /* In PyArg_ParseTuple below, we use the unsigned non-checked 'I'
++ /* In PyArg_ParseTuple below, we use the unsigned non-checked 'k'
+ format for the 'code' parameter because Python turns 0x8000000
+ into either a large positive number (PyLong or PyInt on 64-bit
+ platforms) or a negative number on others (32-bit PyInt)
+ whereas the system expects it to be a 32bit bit field value
+ regardless of it being passed as an int or unsigned long on
+- various platforms. See the termios.TIOCSWINSZ constant across
+- platforms for an example of thise.
+-
+- If any of the 64bit platforms ever decide to use more than 32bits
+- in their unsigned long ioctl codes this will break and need
+- special casing based on the platform being built on.
++ various platforms.
+ */
+- unsigned int code;
++ unsigned long code;
+ int arg;
+ int ret;
+ char *str;
+@@ -118,7 +113,7 @@
+ int mutate_arg = 1;
+ char buf[IOCTL_BUFSZ+1]; /* argument plus NUL byte */
+
+- if (PyArg_ParseTuple(args, "O&Iw#|i:ioctl",
++ if (PyArg_ParseTuple(args, "O&kw#|i:ioctl",
+ conv_descriptor, &fd, &code,
+ &str, &len, &mutate_arg)) {
+ char *arg;
+@@ -169,7 +164,7 @@
+ }
+
+ PyErr_Clear();
+- if (PyArg_ParseTuple(args, "O&Is#:ioctl",
++ if (PyArg_ParseTuple(args, "O&ks#:ioctl",
+ conv_descriptor, &fd, &code, &str, &len)) {
+ if (len > IOCTL_BUFSZ) {
+ PyErr_SetString(PyExc_ValueError,
+@@ -191,7 +186,7 @@
+ PyErr_Clear();
+ arg = 0;
+ if (!PyArg_ParseTuple(args,
+- "O&I|i;ioctl requires a file or file descriptor,"
++ "O&k|i;ioctl requires a file or file descriptor,"
+ " an integer and optionally an integer or buffer argument",
+ conv_descriptor, &fd, &code, &arg)) {
+ return NULL;
diff --git a/lang/python26/Makefile b/lang/python26/Makefile
index 0eba3df2f32c..e614a36c188e 100644
--- a/lang/python26/Makefile
+++ b/lang/python26/Makefile
@@ -6,6 +6,7 @@
PORTNAME= python26
PORTVERSION= 2.6.5
+PORTREVISION= 1
CATEGORIES= lang python ipv6
MASTER_SITES= ${PYTHON_MASTER_SITES}
MASTER_SITE_SUBDIR= ${PYTHON_MASTER_SITE_SUBDIR}
diff --git a/lang/python26/files/patch-Doc-library-fcntl.rst b/lang/python26/files/patch-Doc-library-fcntl.rst
new file mode 100644
index 000000000000..58019637a5f6
--- /dev/null
+++ b/lang/python26/files/patch-Doc-library-fcntl.rst
@@ -0,0 +1,11 @@
+--- Doc/library/fcntl.rst.orig 2009-10-27 10:29:22.000000000 -0400
++++ Doc/library/fcntl.rst 2010-06-24 22:28:28.000000000 -0400
+@@ -50,8 +50,6 @@
+ operations are typically defined in the library module :mod:`termios` and the
+ argument handling is even more complicated.
+
+- The op parameter is limited to values that can fit in 32-bits.
+-
+ The parameter *arg* can be one of an integer, absent (treated identically to the
+ integer ``0``), an object supporting the read-only buffer interface (most likely
+ a plain Python string) or an object supporting the read-write buffer interface.
diff --git a/lang/python26/files/patch-Lib-test-test_ioctl.py b/lang/python26/files/patch-Lib-test-test_ioctl.py
new file mode 100644
index 000000000000..f1fdd0ee5fe3
--- /dev/null
+++ b/lang/python26/files/patch-Lib-test-test_ioctl.py
@@ -0,0 +1,23 @@
+--- Lib/test/test_ioctl.py.orig 2008-05-24 05:36:45.000000000 -0400
++++ Lib/test/test_ioctl.py 2010-06-24 13:29:31.000000000 -0400
+@@ -44,18 +44,9 @@ class IoctlTests(unittest.TestCase):
+ raise TestSkipped('pty module required')
+ mfd, sfd = pty.openpty()
+ try:
+- if termios.TIOCSWINSZ < 0:
+- set_winsz_opcode_maybe_neg = termios.TIOCSWINSZ
+- set_winsz_opcode_pos = termios.TIOCSWINSZ & 0xffffffffL
+- else:
+- set_winsz_opcode_pos = termios.TIOCSWINSZ
+- set_winsz_opcode_maybe_neg, = struct.unpack("i",
+- struct.pack("I", termios.TIOCSWINSZ))
+-
++ set_winsz_opcode = termios.TIOCSWINSZ
+ our_winsz = struct.pack("HHHH",80,25,0,0)
+- # test both with a positive and potentially negative ioctl code
+- new_winsz = fcntl.ioctl(mfd, set_winsz_opcode_pos, our_winsz)
+- new_winsz = fcntl.ioctl(mfd, set_winsz_opcode_maybe_neg, our_winsz)
++ new_winsz = fcntl.ioctl(mfd, set_winsz_opcode, our_winsz)
+ finally:
+ os.close(mfd)
+ os.close(sfd)
diff --git a/lang/python26/files/patch-Modules-fcntlmodule.c b/lang/python26/files/patch-Modules-fcntlmodule.c
new file mode 100644
index 000000000000..b8dfd783eca7
--- /dev/null
+++ b/lang/python26/files/patch-Modules-fcntlmodule.c
@@ -0,0 +1,53 @@
+--- Modules/fcntlmodule.c.orig 2009-05-24 11:41:43.000000000 -0400
++++ Modules/fcntlmodule.c 2010-06-24 22:27:04.000000000 -0400
+@@ -97,20 +97,15 @@
+ {
+ #define IOCTL_BUFSZ 1024
+ int fd;
+- /* In PyArg_ParseTuple below, we use the unsigned non-checked 'I'
++ /* In PyArg_ParseTuple below, we use the unsigned non-checked 'k'
+ format for the 'code' parameter because Python turns 0x8000000
+ into either a large positive number (PyLong or PyInt on 64-bit
+ platforms) or a negative number on others (32-bit PyInt)
+ whereas the system expects it to be a 32bit bit field value
+ regardless of it being passed as an int or unsigned long on
+- various platforms. See the termios.TIOCSWINSZ constant across
+- platforms for an example of thise.
+-
+- If any of the 64bit platforms ever decide to use more than 32bits
+- in their unsigned long ioctl codes this will break and need
+- special casing based on the platform being built on.
++ various platforms.
+ */
+- unsigned int code;
++ unsigned long code;
+ int arg;
+ int ret;
+ char *str;
+@@ -118,7 +113,7 @@
+ int mutate_arg = 1;
+ char buf[IOCTL_BUFSZ+1]; /* argument plus NUL byte */
+
+- if (PyArg_ParseTuple(args, "O&Iw#|i:ioctl",
++ if (PyArg_ParseTuple(args, "O&kw#|i:ioctl",
+ conv_descriptor, &fd, &code,
+ &str, &len, &mutate_arg)) {
+ char *arg;
+@@ -169,7 +164,7 @@
+ }
+
+ PyErr_Clear();
+- if (PyArg_ParseTuple(args, "O&Is#:ioctl",
++ if (PyArg_ParseTuple(args, "O&ks#:ioctl",
+ conv_descriptor, &fd, &code, &str, &len)) {
+ if (len > IOCTL_BUFSZ) {
+ PyErr_SetString(PyExc_ValueError,
+@@ -191,7 +186,7 @@
+ PyErr_Clear();
+ arg = 0;
+ if (!PyArg_ParseTuple(args,
+- "O&I|i;ioctl requires a file or file descriptor,"
++ "O&k|i;ioctl requires a file or file descriptor,"
+ " an integer and optionally an integer or buffer argument",
+ conv_descriptor, &fd, &code, &arg)) {
+ return NULL;
diff --git a/lang/python31/Makefile b/lang/python31/Makefile
index 3c5989272d41..5c0f76ae8343 100644
--- a/lang/python31/Makefile
+++ b/lang/python31/Makefile
@@ -6,6 +6,7 @@
PORTNAME= python31
PORTVERSION= 3.1.2
+PORTREVISION= 1
CATEGORIES= lang python ipv6
MASTER_SITES= ${PYTHON_MASTER_SITES}
MASTER_SITE_SUBDIR= ${PYTHON_MASTER_SITE_SUBDIR}
diff --git a/lang/python31/files/patch-Doc-library-fcntl.rst b/lang/python31/files/patch-Doc-library-fcntl.rst
new file mode 100644
index 000000000000..46c072e1c062
--- /dev/null
+++ b/lang/python31/files/patch-Doc-library-fcntl.rst
@@ -0,0 +1,11 @@
+--- Doc/library/fcntl.rst.orig 2009-06-08 09:41:29.000000000 -0400
++++ Doc/library/fcntl.rst 2010-06-24 22:31:02.000000000 -0400
+@@ -48,8 +48,6 @@
+ This function is identical to the :func:`fcntl` function, except that the
+ argument handling is even more complicated.
+
+- The op parameter is limited to values that can fit in 32-bits.
+-
+ The parameter *arg* can be one of an integer, absent (treated identically to the
+ integer ``0``), an object supporting the read-only buffer interface (most likely
+ a plain Python string) or an object supporting the read-write buffer interface.
diff --git a/lang/python31/files/patch-Lib-test-test_fcntl.py b/lang/python31/files/patch-Lib-test-test_fcntl.py
new file mode 100644
index 000000000000..62104a2da20e
--- /dev/null
+++ b/lang/python31/files/patch-Lib-test-test_fcntl.py
@@ -0,0 +1,11 @@
+--- Lib/test/test_fcntl.py.orig 2009-05-24 11:46:13.000000000 -0400
++++ Lib/test/test_fcntl.py 2010-06-24 13:56:52.000000000 -0400
+@@ -29,7 +29,7 @@
+ if sys.platform in ('netbsd1', 'netbsd2', 'netbsd3',
+ 'Darwin1.2', 'darwin',
+ 'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5',
+- 'freebsd6', 'freebsd7', 'freebsd8',
++ 'freebsd6', 'freebsd7', 'freebsd8', 'freebsd9',
+ 'bsdos2', 'bsdos3', 'bsdos4',
+ 'openbsd', 'openbsd2', 'openbsd3', 'openbsd4'):
+ if struct.calcsize('l') == 8:
diff --git a/lang/python31/files/patch-Lib-test-test_ioctl.py b/lang/python31/files/patch-Lib-test-test_ioctl.py
new file mode 100644
index 000000000000..2488bc755583
--- /dev/null
+++ b/lang/python31/files/patch-Lib-test-test_ioctl.py
@@ -0,0 +1,23 @@
+--- Lib/test/test_ioctl.py.orig 2009-08-13 04:51:18.000000000 -0400
++++ Lib/test/test_ioctl.py 2010-06-24 13:35:29.000000000 -0400
+@@ -41,18 +41,9 @@ class IoctlTests(unittest.TestCase):
+ raise unittest.SkipTest('pty module required')
+ mfd, sfd = pty.openpty()
+ try:
+- if termios.TIOCSWINSZ < 0:
+- set_winsz_opcode_maybe_neg = termios.TIOCSWINSZ
+- set_winsz_opcode_pos = termios.TIOCSWINSZ & 0xffffffff
+- else:
+- set_winsz_opcode_pos = termios.TIOCSWINSZ
+- set_winsz_opcode_maybe_neg, = struct.unpack("i",
+- struct.pack("I", termios.TIOCSWINSZ))
+-
++ set_winsz_opcode = termios.TIOCSWINSZ
+ our_winsz = struct.pack("HHHH",80,25,0,0)
+- # test both with a positive and potentially negative ioctl code
+- new_winsz = fcntl.ioctl(mfd, set_winsz_opcode_pos, our_winsz)
+- new_winsz = fcntl.ioctl(mfd, set_winsz_opcode_maybe_neg, our_winsz)
++ new_winsz = fcntl.ioctl(mfd, set_winsz_opcode, our_winsz)
+ finally:
+ os.close(mfd)
+ os.close(sfd)
diff --git a/lang/python31/files/patch-Lib-test-test_socket.py b/lang/python31/files/patch-Lib-test-test_socket.py
new file mode 100644
index 000000000000..4895d7bc5fc8
--- /dev/null
+++ b/lang/python31/files/patch-Lib-test-test_socket.py
@@ -0,0 +1,11 @@
+--- Lib/test/test_socket.py.orig 2009-10-04 10:54:52.000000000 -0400
++++ Lib/test/test_socket.py 2010-06-24 13:57:37.000000000 -0400
+@@ -337,7 +337,7 @@
+ # I've ordered this by protocols that have both a tcp and udp
+ # protocol, at least for modern Linuxes.
+ if sys.platform in ('linux2', 'freebsd4', 'freebsd5', 'freebsd6',
+- 'freebsd7', 'freebsd8', 'darwin'):
++ 'freebsd7', 'freebsd8', 'freebsd9', 'darwin'):
+ # avoid the 'echo' service on this platform, as there is an
+ # assumption breaking non-standard port/protocol entry
+ services = ('daytime', 'qotd', 'domain')
diff --git a/lang/python31/files/patch-Modules-fcntlmodule.c b/lang/python31/files/patch-Modules-fcntlmodule.c
new file mode 100644
index 000000000000..3803ad427fbe
--- /dev/null
+++ b/lang/python31/files/patch-Modules-fcntlmodule.c
@@ -0,0 +1,53 @@
+--- Modules/fcntlmodule.c.orig 2009-05-24 11:46:13.000000000 -0400
++++ Modules/fcntlmodule.c 2010-06-24 22:30:32.000000000 -0400
+@@ -97,20 +97,15 @@
+ {
+ #define IOCTL_BUFSZ 1024
+ int fd;
+- /* In PyArg_ParseTuple below, we use the unsigned non-checked 'I'
++ /* In PyArg_ParseTuple below, we use the unsigned non-checked 'k'
+ format for the 'code' parameter because Python turns 0x8000000
+ into either a large positive number (PyLong or PyInt on 64-bit
+ platforms) or a negative number on others (32-bit PyInt)
+ whereas the system expects it to be a 32bit bit field value
+ regardless of it being passed as an int or unsigned long on
+- various platforms. See the termios.TIOCSWINSZ constant across
+- platforms for an example of thise.
+-
+- If any of the 64bit platforms ever decide to use more than 32bits
+- in their unsigned long ioctl codes this will break and need
+- special casing based on the platform being built on.
++ various platforms.
+ */
+- unsigned int code;
++ unsigned long code;
+ int arg;
+ int ret;
+ Py_buffer pstr;
+@@ -119,7 +114,7 @@
+ int mutate_arg = 1;
+ char buf[IOCTL_BUFSZ+1]; /* argument plus NUL byte */
+
+- if (PyArg_ParseTuple(args, "O&Iw*|i:ioctl",
++ if (PyArg_ParseTuple(args, "O&kw*|i:ioctl",
+ conv_descriptor, &fd, &code,
+ &pstr, &mutate_arg)) {
+ char *arg;
+@@ -174,7 +169,7 @@
+ }
+
+ PyErr_Clear();
+- if (PyArg_ParseTuple(args, "O&Is*:ioctl",
++ if (PyArg_ParseTuple(args, "O&ks*:ioctl",
+ conv_descriptor, &fd, &code, &pstr)) {
+ str = pstr.buf;
+ len = pstr.len;
+@@ -201,7 +196,7 @@
+ PyErr_Clear();
+ arg = 0;
+ if (!PyArg_ParseTuple(args,
+- "O&I|i;ioctl requires a file or file descriptor,"
++ "O&k|i;ioctl requires a file or file descriptor,"
+ " an integer and optionally an integer or buffer argument",
+ conv_descriptor, &fd, &code, &arg)) {
+ return NULL;
diff --git a/lang/python32/Makefile b/lang/python32/Makefile
index 3c5989272d41..5c0f76ae8343 100644
--- a/lang/python32/Makefile
+++ b/lang/python32/Makefile
@@ -6,6 +6,7 @@
PORTNAME= python31
PORTVERSION= 3.1.2
+PORTREVISION= 1
CATEGORIES= lang python ipv6
MASTER_SITES= ${PYTHON_MASTER_SITES}
MASTER_SITE_SUBDIR= ${PYTHON_MASTER_SITE_SUBDIR}
diff --git a/lang/python32/files/patch-Doc-library-fcntl.rst b/lang/python32/files/patch-Doc-library-fcntl.rst
new file mode 100644
index 000000000000..46c072e1c062
--- /dev/null
+++ b/lang/python32/files/patch-Doc-library-fcntl.rst
@@ -0,0 +1,11 @@
+--- Doc/library/fcntl.rst.orig 2009-06-08 09:41:29.000000000 -0400
++++ Doc/library/fcntl.rst 2010-06-24 22:31:02.000000000 -0400
+@@ -48,8 +48,6 @@
+ This function is identical to the :func:`fcntl` function, except that the
+ argument handling is even more complicated.
+
+- The op parameter is limited to values that can fit in 32-bits.
+-
+ The parameter *arg* can be one of an integer, absent (treated identically to the
+ integer ``0``), an object supporting the read-only buffer interface (most likely
+ a plain Python string) or an object supporting the read-write buffer interface.
diff --git a/lang/python32/files/patch-Lib-test-test_fcntl.py b/lang/python32/files/patch-Lib-test-test_fcntl.py
new file mode 100644
index 000000000000..62104a2da20e
--- /dev/null
+++ b/lang/python32/files/patch-Lib-test-test_fcntl.py
@@ -0,0 +1,11 @@
+--- Lib/test/test_fcntl.py.orig 2009-05-24 11:46:13.000000000 -0400
++++ Lib/test/test_fcntl.py 2010-06-24 13:56:52.000000000 -0400
+@@ -29,7 +29,7 @@
+ if sys.platform in ('netbsd1', 'netbsd2', 'netbsd3',
+ 'Darwin1.2', 'darwin',
+ 'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5',
+- 'freebsd6', 'freebsd7', 'freebsd8',
++ 'freebsd6', 'freebsd7', 'freebsd8', 'freebsd9',
+ 'bsdos2', 'bsdos3', 'bsdos4',
+ 'openbsd', 'openbsd2', 'openbsd3', 'openbsd4'):
+ if struct.calcsize('l') == 8:
diff --git a/lang/python32/files/patch-Lib-test-test_ioctl.py b/lang/python32/files/patch-Lib-test-test_ioctl.py
new file mode 100644
index 000000000000..2488bc755583
--- /dev/null
+++ b/lang/python32/files/patch-Lib-test-test_ioctl.py
@@ -0,0 +1,23 @@
+--- Lib/test/test_ioctl.py.orig 2009-08-13 04:51:18.000000000 -0400
++++ Lib/test/test_ioctl.py 2010-06-24 13:35:29.000000000 -0400
+@@ -41,18 +41,9 @@ class IoctlTests(unittest.TestCase):
+ raise unittest.SkipTest('pty module required')
+ mfd, sfd = pty.openpty()
+ try:
+- if termios.TIOCSWINSZ < 0:
+- set_winsz_opcode_maybe_neg = termios.TIOCSWINSZ
+- set_winsz_opcode_pos = termios.TIOCSWINSZ & 0xffffffff
+- else:
+- set_winsz_opcode_pos = termios.TIOCSWINSZ
+- set_winsz_opcode_maybe_neg, = struct.unpack("i",
+- struct.pack("I", termios.TIOCSWINSZ))
+-
++ set_winsz_opcode = termios.TIOCSWINSZ
+ our_winsz = struct.pack("HHHH",80,25,0,0)
+- # test both with a positive and potentially negative ioctl code
+- new_winsz = fcntl.ioctl(mfd, set_winsz_opcode_pos, our_winsz)
+- new_winsz = fcntl.ioctl(mfd, set_winsz_opcode_maybe_neg, our_winsz)
++ new_winsz = fcntl.ioctl(mfd, set_winsz_opcode, our_winsz)
+ finally:
+ os.close(mfd)
+ os.close(sfd)
diff --git a/lang/python32/files/patch-Lib-test-test_socket.py b/lang/python32/files/patch-Lib-test-test_socket.py
new file mode 100644
index 000000000000..4895d7bc5fc8
--- /dev/null
+++ b/lang/python32/files/patch-Lib-test-test_socket.py
@@ -0,0 +1,11 @@
+--- Lib/test/test_socket.py.orig 2009-10-04 10:54:52.000000000 -0400
++++ Lib/test/test_socket.py 2010-06-24 13:57:37.000000000 -0400
+@@ -337,7 +337,7 @@
+ # I've ordered this by protocols that have both a tcp and udp
+ # protocol, at least for modern Linuxes.
+ if sys.platform in ('linux2', 'freebsd4', 'freebsd5', 'freebsd6',
+- 'freebsd7', 'freebsd8', 'darwin'):
++ 'freebsd7', 'freebsd8', 'freebsd9', 'darwin'):
+ # avoid the 'echo' service on this platform, as there is an
+ # assumption breaking non-standard port/protocol entry
+ services = ('daytime', 'qotd', 'domain')
diff --git a/lang/python32/files/patch-Modules-fcntlmodule.c b/lang/python32/files/patch-Modules-fcntlmodule.c
new file mode 100644
index 000000000000..3803ad427fbe
--- /dev/null
+++ b/lang/python32/files/patch-Modules-fcntlmodule.c
@@ -0,0 +1,53 @@
+--- Modules/fcntlmodule.c.orig 2009-05-24 11:46:13.000000000 -0400
++++ Modules/fcntlmodule.c 2010-06-24 22:30:32.000000000 -0400
+@@ -97,20 +97,15 @@
+ {
+ #define IOCTL_BUFSZ 1024
+ int fd;
+- /* In PyArg_ParseTuple below, we use the unsigned non-checked 'I'
++ /* In PyArg_ParseTuple below, we use the unsigned non-checked 'k'
+ format for the 'code' parameter because Python turns 0x8000000
+ into either a large positive number (PyLong or PyInt on 64-bit
+ platforms) or a negative number on others (32-bit PyInt)
+ whereas the system expects it to be a 32bit bit field value
+ regardless of it being passed as an int or unsigned long on
+- various platforms. See the termios.TIOCSWINSZ constant across
+- platforms for an example of thise.
+-
+- If any of the 64bit platforms ever decide to use more than 32bits
+- in their unsigned long ioctl codes this will break and need
+- special casing based on the platform being built on.
++ various platforms.
+ */
+- unsigned int code;
++ unsigned long code;
+ int arg;
+ int ret;
+ Py_buffer pstr;
+@@ -119,7 +114,7 @@
+ int mutate_arg = 1;
+ char buf[IOCTL_BUFSZ+1]; /* argument plus NUL byte */
+
+- if (PyArg_ParseTuple(args, "O&Iw*|i:ioctl",
++ if (PyArg_ParseTuple(args, "O&kw*|i:ioctl",
+ conv_descriptor, &fd, &code,
+ &pstr, &mutate_arg)) {
+ char *arg;
+@@ -174,7 +169,7 @@
+ }
+
+ PyErr_Clear();
+- if (PyArg_ParseTuple(args, "O&Is*:ioctl",
++ if (PyArg_ParseTuple(args, "O&ks*:ioctl",
+ conv_descriptor, &fd, &code, &pstr)) {
+ str = pstr.buf;
+ len = pstr.len;
+@@ -201,7 +196,7 @@
+ PyErr_Clear();
+ arg = 0;
+ if (!PyArg_ParseTuple(args,
+- "O&I|i;ioctl requires a file or file descriptor,"
++ "O&k|i;ioctl requires a file or file descriptor,"
+ " an integer and optionally an integer or buffer argument",
+ conv_descriptor, &fd, &code, &arg)) {
+ return NULL;