Index: Mk/bsd.python.mk
===================================================================
--- Mk/bsd.python.mk
+++ Mk/bsd.python.mk
@@ -381,9 +381,9 @@
 
 # Python-2.7
 .elif ${PYTHON_VERSION} == "python2.7"
-PYTHON_PORTVERSION?=	2.7.6
+PYTHON_PORTVERSION?=	2.7.8
 PYTHON_PORTSDIR=	${PORTSDIR}/lang/python27
-PYTHON_REL=		276
+PYTHON_REL=		278
 PYTHON_SUFFIX=		27
 PYTHON_VER=		2.7
 
Index: devel/py-setuptools/Makefile
===================================================================
--- devel/py-setuptools/Makefile
+++ devel/py-setuptools/Makefile
@@ -1,7 +1,7 @@
 # $FreeBSD$
 
 PORTNAME=	setuptools
-PORTVERSION=	5.1
+PORTVERSION=	5.4.1
 CATEGORIES=	devel python
 MASTER_SITES=	CHEESESHOP
 PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
@@ -17,7 +17,7 @@
 PLIST_SUB=	PYVER=${PYTHON_VER} VERSION=${PORTVERSION} \
 		EASYINSTALL_PTH=${PYTHON_SITELIBDIR}/easy-install.pth
 
-USE_PYTHON=	yes
+USE_PYTHON=		yes
 USE_PYDISTUTILS=	yes
 PYDISTUTILS_AUTOPLIST=	yes
 PYDISTUTILS_SETUP=	${PYSETUP}
Index: devel/py-setuptools/distinfo
===================================================================
--- devel/py-setuptools/distinfo
+++ devel/py-setuptools/distinfo
@@ -1,2 +1,2 @@
-SHA256 (python/setuptools-5.1.tar.gz) = 5855a13607cae9123df0981d814d32b5b413b7a20422f642bf3f4c355383485b
-SIZE (python/setuptools-5.1.tar.gz) = 804805
+SHA256 (python/setuptools-5.4.1.tar.gz) = 41194dc283bd186d5a7825c16b89d88bee369a6c4c4c7494e84909933b6f63be
+SIZE (python/setuptools-5.4.1.tar.gz) = 782761
Index: devel/py-setuptools/files/patch-setuptools__command__install_egg_info.py
===================================================================
--- /dev/null
+++ devel/py-setuptools/files/patch-setuptools__command__install_egg_info.py
@@ -0,0 +1,15 @@
+# install_egg_info command includes directory entries in --record output
+# Issue: https://bitbucket.org/pypa/setuptools/issue/118
+# TODO: Merge upstream
+
+--- ./setuptools/command/install_egg_info.py.orig	2014-06-22 18:00:47.547029977 +1000
++++ ./setuptools/command/install_egg_info.py	2014-06-22 18:01:03.507130973 +1000
+@@ -23,7 +23,7 @@
+         ).egg_name()+'.egg-info'
+         self.source = ei_cmd.egg_info
+         self.target = os.path.join(self.install_dir, basename)
+-        self.outputs = [self.target]
++        self.outputs = []
+ 
+     def run(self):
+         self.run_command('egg_info')
Index: devel/py-setuptools/files/patch-setuptools_command_install_egg_info.py
===================================================================
--- devel/py-setuptools/files/patch-setuptools_command_install_egg_info.py
+++ /dev/null
@@ -1,11 +0,0 @@
---- setuptools/command/install_egg_info.py.orig	2013-11-27 22:45:15.000000000 +0100
-+++ setuptools/command/install_egg_info.py	2013-11-27 22:45:23.000000000 +0100
-@@ -23,7 +23,7 @@
-         ).egg_name()+'.egg-info'
-         self.source = ei_cmd.egg_info
-         self.target = os.path.join(self.install_dir, basename)
--        self.outputs = [self.target]
-+        self.outputs = []
- 
-     def run(self):
-         self.run_command('egg_info')
Index: lang/python27/Makefile
===================================================================
--- lang/python27/Makefile
+++ lang/python27/Makefile
@@ -2,8 +2,7 @@
 # $FreeBSD$
 
 PORTNAME=	python27
-PORTVERSION=	2.7.6
-PORTREVISION=	4
+PORTVERSION=	2.7.8
 CATEGORIES=	lang python ipv6
 MASTER_SITES=	PYTHON
 MASTER_SITE_SUBDIR=	${PYTHON_MASTER_SITE_SUBDIR}
@@ -42,9 +41,6 @@
 EXAMPLESDIR=	${PREFIX}/share/examples/${PYTHON_VERSION}
 DATADIR=	${PREFIX}/share/${PYTHON_VERSION}
 
-PLATFORMS=	plat-freebsd6 plat-freebsd7 plat-freebsd8 plat-freebsd9 \
-		plat-freebsd10 plat-freebsd11
-
 BIN_SCRIPTS=	2to3 idle pydoc smtpd.py
 BIN_FILES=	python python-shared python-config python-shared-config \
 		${BIN_SCRIPTS}
@@ -53,34 +49,38 @@
 			-e 's,(idle|pydoc|python-shared|python),\1%%VERSION%%,'
 BINLINKS_SUB_PYTHON_VER=	${BINLINKS_SUB_TMPL:S/%%VERSION%%/${PYTHON_VER}/g}
 
-OPTIONS_DEFINE=		THREADS SEM PTH PYMALLOC IPV6 FPECTL EXAMPLES NLS
-OPTIONS_DEFAULT=	THREADS UCS4 PYMALLOC IPV6
+OPTIONS_DEFINE=		EXAMPLES FPECTL IPV6 NLS PTH PYMALLOC SEM THREADS
+OPTIONS_DEFAULT=	IPV6 PYMALLOC SEM THREADS UCS4
 
-OPTIONS_SINGLE=		UCS
-OPTIONS_SINGLE_UCS=	UCS2 UCS4
+OPTIONS_SINGLE=		UNICODE
+OPTIONS_SINGLE_UNICODE=	UCS2 UCS4
 
 NLS_DESC=	Enable Gettext support for the locale module
+UCS2_DESC=	Enable UCS2 Unicode Strings
+UCS4_DESC=	Enable ECS4 Unicode Strings
 
-.include <bsd.port.options.mk>
+FPECTL_CONFIGURE_ON=	--with-fpectl
+IPV6_CONFIGURE_ENABLE=	ipv6
 
-.if ${PORT_OPTIONS:MNLS}
-USES+=		gettext
-CPPFLAGS+=	-I${LOCALBASE}/include
-LIBS+=		-L${LOCALBASE}/lib -lintl
-.else
-CONFIGURE_ENV+=	ac_cv_lib_intl_textdomain=no ac_cv_header_libintl_h=no
-.endif
+# Use CPPFLAGS over CFLAGS due to -I ordering, causing elementtree and pyexpat
+# to break in Python 2.7, or preprocessor complaints in Python >= 3.3
+# Upstream Issue: http://bugs.python.org/issue6299
+NLS_USES=		gettext
+NLS_CPPFLAGS=		-I${LOCALBASE}/include
+NLS_LIBS=		-L${LOCALBASE}/lib -lintl
+NLS_CONFIGURE_ENV_OFF=	ac_cv_lib_intl_textdomain=no ac_cv_header_libintl_h=no
 
-.include <bsd.port.pre.mk>
+PYMALLOC_CONFIGURE_WITH=	pymalloc
 
-.if ${PORT_OPTIONS:MSEM}
-SEM_MSG=	""
-.else
-SEM_MSG=	"@comment "
-.endif
+SEM_CONFIGURE_ENV=	ac_cv_posix_semaphores_enabled=yes
+SEM_CONFIGURE_ENV_OFF=	ac_cv_posix_semaphores_enabled=no
+
+UCS2_CONFIGURE_ON=	--enable-unicode=ucs2
+UCS4_CONFIGURE_ON=	--enable-unicode=ucs4
+
+.include <bsd.port.pre.mk>
 
 SUB_FILES=	pkg-message
-SUB_LIST=	SEM=${SEM_MSG}
 
 .if ${PORT_OPTIONS:MTHREADS}
 PLIST_SUB+=	THREADS=""
@@ -103,18 +103,6 @@
 CONFIGURE_ARGS+=	--without-threads
 .endif
 
-.if ${PORT_OPTIONS:MUCS4}
-CONFIGURE_ARGS+=	--enable-unicode=ucs4
-.endif
-
-.if ${PORT_OPTIONS:MUCS2}
-CONFIGURE_ARGS+=	--enable-unicode=ucs2
-.endif
-
-.if empty(PORT_OPTIONS:MPYMALLOC)
-CONFIGURE_ARGS+=	--without-pymalloc
-.endif
-
 .if ${ARCH} == i386
 PLIST_SUB+=	X86_ONLY=""
 .else
@@ -140,16 +128,6 @@
 PLIST_SUB+=	NO_NIS=""
 .endif
 
-.if ${PORT_OPTIONS:MIPV6}
-CONFIGURE_ARGS+=	--enable-ipv6
-.else
-CONFIGURE_ARGS+=	--disable-ipv6
-.endif
-
-.if ${PORT_OPTIONS:MFPECTL}
-CONFIGURE_ARGS+=	--with-fpectl
-.endif
-
 CONFIGURE_ENV+=	OPT="${_PTH_CPPFLAGS}"
 
 post-extract:
@@ -159,12 +137,6 @@
 	${CHMOD} -R og=u-w ${PYTHON_WRKSRC}/Tools ${PYTHON_WRKSRC}/Demo
 
 pre-patch:
-	${CP} -r ${PATCH_WRKSRC}/Lib/plat-freebsd8 \
-		${PATCH_WRKSRC}/Lib/plat-freebsd9
-	${CP} -r ${PATCH_WRKSRC}/Lib/plat-freebsd8 \
-		${PATCH_WRKSRC}/Lib/plat-freebsd10
-	${CP} -r ${PATCH_WRKSRC}/Lib/plat-freebsd8 \
-		${PATCH_WRKSRC}/Lib/plat-freebsd11
 	${MKDIR} ${WRKSRC} ${SHARED_WRKSRC}/Modules
 	${LN} ${PATCH_WRKSRC}/Lib/smtpd.py ${PATCH_WRKSRC}/Tools/scripts/
 .for script in ${BIN_SCRIPTS}
@@ -226,15 +198,6 @@
 	${LN} -f lib${PYTHON_VERSION}.so lib${PYTHON_VERSION}.so.1; \
 	${LN} -f python ${PYTHON_VERSION:S/thon/thon-shared/}
 
-pre-su-install:
-.for platform in ${PLATFORMS}
-	${MKDIR} ${STAGEDIR}${PYTHONPREFIX_LIBDIR}/${platform}
-.for file in IN.py regen
-	${INSTALL_DATA} ${WRKSRC}/Lib/${platform}/${file} \
-		${STAGEDIR}${PYTHONPREFIX_LIBDIR}/${platform}/
-.endfor
-.endfor
-
 pre-install:
 	${CAT} ${PLIST_TEMPLATE} | ${AWK} '{ print $$0; } \
 	/LIBDIR.*\.py$$/ && \
@@ -271,15 +234,13 @@
 .endfor
 	${INSTALL_MAN} ${PYTHON_WRKSRC}/Misc/python.man \
 		${STAGEDIR}${MAN1PREFIX}/man/man1/${PYTHON_VERSION}.1
-
-.if !defined(NOPORTDATA)
 	@${MKDIR} ${STAGEDIR}${DATADIR}
 	@(cd ${PYTHON_WRKSRC}; ${TAR} -cf - Tools | (cd ${STAGEDIR}${DATADIR}; ${TAR} --no-same-owner -xf -))
-.endif
 	@${MKDIR} ${STAGEDIR}${EXAMPLESDIR}
 	@(cd ${PYTHON_WRKSRC}/Demo; ${TAR} -cf - * | \
 		(cd ${STAGEDIR}${EXAMPLESDIR}; ${TAR} --no-same-owner -xf -))
 
-	@${CAT} ${PKGMESSAGE}
+regression-test: build
+	@cd ${WRKSRC} && ${MAKE} TESTOPTS=-j${MAKE_JOBS_NUMBER} buildbottest
 
 .include <bsd.port.post.mk>
Index: lang/python27/distinfo
===================================================================
--- lang/python27/distinfo
+++ lang/python27/distinfo
@@ -1,2 +1,2 @@
-SHA256 (python/Python-2.7.6.tar.xz) = 1fd68e81f8bf7386ff239b7faee9ba387129d2cf34eab13350bd8503a0bff6a1
-SIZE (python/Python-2.7.6.tar.xz) = 10431288
+SHA256 (python/Python-2.7.8.tar.xz) = edde10a0cb7d14e2735e682882d5b287028d1485c456758154c19573db68075a
+SIZE (python/Python-2.7.8.tar.xz) = 10525244
Index: lang/python27/files/patch-CVE-2014-1912
===================================================================
--- lang/python27/files/patch-CVE-2014-1912
+++ /dev/null
@@ -1,50 +0,0 @@
-# HG changeset patch
-# User Benjamin Peterson <benjamin@python.org>
-# Date 1389671978 18000
-# Node ID 87673659d8f7ba1623cd4914f09ad3d2ade034e9
-# Parent  2631d33ee7fbd5f0288931ef37872218d511d2e8
-complain when nbytes > buflen to fix possible buffer overflow (closes #20246)
-
-# HG changeset patch
-# User Stefan Krah <skrah@bytereef.org>
-# Date 1390341952 -3600
-# Node ID b6c5a37b221f5c617125faa363d1b460b0b61b42
-# Parent  d55d1cbf5f9a9efa7908fc9412bae676a6b675ef
-Issue #20246: Fix test failures on FreeBSD. Patch by Ryan Smith-Roberts.
-
-diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
---- Lib/test/test_socket.py
-+++ Lib/test/test_socket.py
-@@ -1620,6 +1620,16 @@ class BufferIOTest(SocketConnectedTest):
- 
-     _testRecvFromIntoMemoryview = _testRecvFromIntoArray
- 
-+    def testRecvFromIntoSmallBuffer(self):
-+        # See issue #20246.
-+        buf = bytearray(8)
-+        self.assertRaises(ValueError, self.cli_conn.recvfrom_into, buf, 1024)
-+
-+    def _testRecvFromIntoSmallBuffer(self):
-+        with test_support.check_py3k_warnings():
-+            buf = buffer(MSG)
-+        self.serv_conn.send(buf)
-+
- 
- TIPC_STYPE = 2000
- TIPC_LOWER = 200
- 
-diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
---- Modules/socketmodule.c
-+++ Modules/socketmodule.c
-@@ -2742,6 +2742,10 @@ sock_recvfrom_into(PySocketSockObject *s
-     if (recvlen == 0) {
-         /* If nbytes was not specified, use the buffer's length */
-         recvlen = buflen;
-+    } else if (recvlen > buflen) {
-+        PyErr_SetString(PyExc_ValueError,
-+                        "nbytes is greater than the length of the buffer");
-+        goto error;
-     }
- 
-     readlen = sock_recvfrom_guts(s, buf.buf, recvlen, flags, &addr);
-
Index: lang/python27/files/patch-Doc-library-fcntl.rst
===================================================================
--- lang/python27/files/patch-Doc-library-fcntl.rst
+++ /dev/null
@@ -1,11 +0,0 @@
---- Doc/library/fcntl.rst.orig	2010-08-14 16:19:09.194215129 +0800
-+++ Doc/library/fcntl.rst	2010-08-14 16:19:36.999453016 +0800
-@@ -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.
Index: lang/python27/files/patch-Doc__library__fcntl.rst
===================================================================
--- /dev/null
+++ lang/python27/files/patch-Doc__library__fcntl.rst
@@ -0,0 +1,10 @@
+--- ./Doc/library/fcntl.rst.orig	2014-07-03 21:53:41.473098625 +1000
++++ ./Doc/library/fcntl.rst	2014-07-03 21:54:04.342833056 +1000
+@@ -50,7 +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.
+    Additional constants of interest for use as the *op* argument can be
+    found in the :mod:`termios` module, under the same names as used in
+    the relevant C header files.
Index: lang/python27/files/patch-Modules-fcntlmodule.c
===================================================================
--- lang/python27/files/patch-Modules-fcntlmodule.c
+++ /dev/null
@@ -1,53 +0,0 @@
---- Modules/fcntlmodule.c.orig	2010-08-14 16:36:54.991363730 +0800
-+++ Modules/fcntlmodule.c	2010-08-14 16:41:05.555822031 +0800
-@@ -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;
Index: lang/python27/files/patch-Modules__fcntlmodule.c
===================================================================
--- /dev/null
+++ lang/python27/files/patch-Modules__fcntlmodule.c
@@ -0,0 +1,53 @@
+--- ./Modules/fcntlmodule.c.orig	2014-07-03 21:57:10.429953240 +1000
++++ ./Modules/fcntlmodule.c	2014-07-03 21:59:36.517210444 +1000
+@@ -98,20 +98,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 this.
+-
+-       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;
+@@ -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,
+                          &str, &len, &mutate_arg)) {
+         char *arg;
+@@ -170,7 +165,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,
+@@ -192,7 +187,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;
Index: lang/python27/files/patch-issue20374
===================================================================
--- lang/python27/files/patch-issue20374
+++ /dev/null
@@ -1,55 +0,0 @@
-# Description: fix readline.so build with readline 6.3
-# Patch obtained from upstream, issue #20374
-# http://bugs.python.org/issue20374
-# PR: ports/187174
-
---- ./Modules/readline.c.orig	2013-11-10 07:36:41.000000000 +0000
-+++ ./Modules/readline.c	2014-03-01 12:40:44.000000000 +0000
-@@ -750,14 +750,22 @@
- }
- 
- static int
-+#if defined(_RL_FUNCTION_TYPEDEF)
- on_startup_hook(void)
-+#else
-+on_startup_hook()
-+#endif
- {
-     return on_hook(startup_hook);
- }
- 
- #ifdef HAVE_RL_PRE_INPUT_HOOK
- static int
-+#if defined(_RL_FUNCTION_TYPEDEF)
- on_pre_input_hook(void)
-+#else
-+on_pre_input_hook()
-+#endif
- {
-     return on_hook(pre_input_hook);
- }
-@@ -852,7 +860,7 @@
-  * before calling the normal completer */
- 
- static char **
--flex_complete(char *text, int start, int end)
-+flex_complete(const char *text, int start, int end)
- {
- #ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
-     rl_completion_append_character ='\0';
-@@ -911,12 +919,12 @@
-     rl_bind_key_in_map ('\t', rl_complete, emacs_meta_keymap);
-     rl_bind_key_in_map ('\033', rl_complete, emacs_meta_keymap);
-     /* Set our hook functions */
--    rl_startup_hook = (Function *)on_startup_hook;
-+    rl_startup_hook = on_startup_hook;
- #ifdef HAVE_RL_PRE_INPUT_HOOK
--    rl_pre_input_hook = (Function *)on_pre_input_hook;
-+    rl_pre_input_hook = on_pre_input_hook;
- #endif
-     /* Set our completion function */
--    rl_attempted_completion_function = (CPPFunction *)flex_complete;
-+    rl_attempted_completion_function = flex_complete;
-     /* Set Python word break characters */
-     completer_word_break_characters =
-         rl_completer_word_break_characters =
Index: lang/python27/files/patch-setup.py
===================================================================
--- lang/python27/files/patch-setup.py
+++ lang/python27/files/patch-setup.py
@@ -1,5 +1,5 @@
---- setup.py.orig	2013-04-06 18:02:41.000000000 +0400
-+++ setup.py	2013-04-07 10:52:47.000000000 +0400
+--- ./setup.py.orig	2014-07-04 18:02:21.711919294 +1000
++++ ./setup.py	2014-07-04 18:11:14.642091269 +1000
 @@ -33,7 +33,7 @@
  COMPILED_WITH_PYDEBUG = ('--with-pydebug' in sysconfig.get_config_var("CONFIG_ARGS"))
  
@@ -9,25 +9,7 @@
  
  def add_dir_to_list(dirlist, dir):
      """Add the directory 'dir' to the list 'dirlist' (at the front) if
-@@ -720,7 +720,7 @@
-         # use the same library for the readline and curses modules.
-         if 'curses' in readline_termcap_library:
-             curses_library = readline_termcap_library
--        elif self.compiler.find_library_file(lib_dirs, 'ncursesw'):
-+        elif self.compiler.find_library_file(lib_dirs, 'xxxncursesw'):
-             curses_library = 'ncursesw'
-         elif self.compiler.find_library_file(lib_dirs, 'ncurses'):
-             curses_library = 'ncurses'
-@@ -755,7 +755,7 @@
-             elif curses_library:
-                 readline_libs.append(curses_library)
-             elif self.compiler.find_library_file(lib_dirs +
--                                                     ['/usr/lib/termcap'],
-+                                                     ['/usr/lib', '/usr/lib/termcap'],
-                                                      'termcap'):
-                 readline_libs.append('termcap')
-             exts.append( Extension('readline', ['readline.c'],
-@@ -862,6 +862,8 @@
+@@ -867,6 +867,8 @@
              # OpenSSL doesn't do these until 0.9.8 so we'll bring our own hash
              exts.append( Extension('_sha256', ['sha256module.c']) )
              exts.append( Extension('_sha512', ['sha512module.c']) )
@@ -36,7 +18,7 @@
  
          # Modules that provide persistent dictionary-like semantics.  You will
          # probably want to arrange for at least one of them to be available on
-@@ -1208,7 +1210,7 @@
+@@ -1212,7 +1214,7 @@
                  sysroot = macosx_sdk_root()
                  f = os.path.join(sysroot, f[1:])
  
@@ -45,30 +27,7 @@
              data = open(f).read()
              m = re.search(r"#s*define\s+HASHVERSION\s+2\s*", data)
              if m is not None:
-@@ -1338,12 +1340,13 @@
-         # provided by the ncurses library.
-         panel_library = 'panel'
-         if curses_library.startswith('ncurses'):
--            if curses_library == 'ncursesw':
-+            if curses_library == 'xxxncursesw':
-                 # Bug 1464056: If _curses.so links with ncursesw,
-                 # _curses_panel.so must link with panelw.
-                 panel_library = 'panelw'
-             curses_libs = [curses_library]
-             exts.append( Extension('_curses', ['_cursesmodule.c'],
-+                                   library_dirs = ['/usr/lib'],
-                                    libraries = curses_libs) )
-         elif curses_library == 'curses' and host_platform != 'darwin':
-                 # OSX has an old Berkeley curses, not good enough for
-@@ -1356,6 +1359,7 @@
-                 curses_libs = ['curses']
- 
-             exts.append( Extension('_curses', ['_cursesmodule.c'],
-+                                   library_dirs = ['/usr/lib'],
-                                    libraries = curses_libs) )
-         else:
-             missing.append('_curses')
-@@ -1540,7 +1544,7 @@
+@@ -1551,7 +1553,7 @@
              macros = dict()
              libraries = []
  
@@ -77,16 +36,21 @@
              # FreeBSD's P1003.1b semaphore support is very experimental
              # and has many known problems. (as of June 2008)
              macros = dict()
-@@ -1592,7 +1596,7 @@
+@@ -1602,9 +1604,10 @@
+         else:
              missing.append('linuxaudiodev')
  
-         if (host_platform in ('linux2', 'freebsd4', 'freebsd5', 'freebsd6',
+-        if (host_platform in ('linux2', 'freebsd4', 'freebsd5', 'freebsd6',
 -                        'freebsd7', 'freebsd8')
-+                        'freebsd7', 'freebsd8', 'freebsd9', 'freebsd10', 'freebsd11')
-             or host_platform.startswith("gnukfreebsd")):
+-            or host_platform.startswith("gnukfreebsd")):
++# Initial backport of http://hg.python.org/cpython/rev/50f1922bc1d5
++
++        if any(sys.platform.startswith(prefix)
++               for prefix in ("linux", "freebsd", "gnukfreebsd")):
              exts.append( Extension('ossaudiodev', ['ossaudiodev.c']) )
          else:
-@@ -2176,9 +2180,7 @@
+             missing.append('ossaudiodev')
+@@ -2228,9 +2231,7 @@
            ext_modules=[Extension('_struct', ['_struct.c'])],
  
            # Scripts to install
Index: lang/python27/files/pkg-message.in
===================================================================
--- lang/python27/files/pkg-message.in
+++ lang/python27/files/pkg-message.in
@@ -1,18 +1,9 @@
-====
-Note that some of the standard modules are provided as separate
-ports since they require extra dependencies:
+=====================================================================
+Note that some standard Python modules are provided as separate ports
+as they require additional dependencies. They are available as:
 
 bsddb           databases/py-bsddb
 gdbm            databases/py-gdbm
 sqlite3         databases/py-sqlite3
 tkinter         x11-toolkits/py-tkinter
-
-Install them as needed.
-====
-%%SEM%%--------------------------------------------------------
-%%SEM%%This package was built with the experimental POSIX
-%%SEM%%semaphore support. Please ensure that the kernel on the
-%%SEM%%system where you deploy this package is either compiled
-%%SEM%%with 'options P1003_1B_SEMAPHORES', or has the sem.ko
-%%SEM%%kernel module loaded.
-%%SEM%%--------------------------------------------------------
+=====================================================================
Index: lang/python27/pkg-plist
===================================================================
--- lang/python27/pkg-plist
+++ lang/python27/pkg-plist
@@ -238,7 +238,6 @@
 %%PYTHON_LIBDIR%%/ctypes/test/test_cfuncs.py
 %%PYTHON_LIBDIR%%/ctypes/test/test_checkretval.py
 %%PYTHON_LIBDIR%%/ctypes/test/test_delattr.py
-%%PYTHON_LIBDIR%%/ctypes/test/test_errcheck.py
 %%PYTHON_LIBDIR%%/ctypes/test/test_errno.py
 %%PYTHON_LIBDIR%%/ctypes/test/test_find.py
 %%PYTHON_LIBDIR%%/ctypes/test/test_frombuffer.py
@@ -246,7 +245,6 @@
 %%PYTHON_LIBDIR%%/ctypes/test/test_functions.py
 %%PYTHON_LIBDIR%%/ctypes/test/test_incomplete.py
 %%PYTHON_LIBDIR%%/ctypes/test/test_init.py
-%%PYTHON_LIBDIR%%/ctypes/test/test_integers.py
 %%PYTHON_LIBDIR%%/ctypes/test/test_internals.py
 %%PYTHON_LIBDIR%%/ctypes/test/test_keeprefs.py
 %%PYTHON_LIBDIR%%/ctypes/test/test_libc.py
@@ -640,6 +638,13 @@
 %%PYTHON_LIBDIR%%/idlelib/HISTORY.txt
 %%PYTHON_LIBDIR%%/idlelib/HyperParser.py
 %%PYTHON_LIBDIR%%/idlelib/IOBinding.py
+%%PYTHON_LIBDIR%%/idlelib/Icons/idle.ico
+%%PYTHON_LIBDIR%%/idlelib/Icons/idle_16.gif
+%%PYTHON_LIBDIR%%/idlelib/Icons/idle_16.png
+%%PYTHON_LIBDIR%%/idlelib/Icons/idle_32.gif
+%%PYTHON_LIBDIR%%/idlelib/Icons/idle_32.png
+%%PYTHON_LIBDIR%%/idlelib/Icons/idle_48.gif
+%%PYTHON_LIBDIR%%/idlelib/Icons/idle_48.png
 %%PYTHON_LIBDIR%%/idlelib/Icons/folder.gif
 %%PYTHON_LIBDIR%%/idlelib/Icons/idle.icns
 %%PYTHON_LIBDIR%%/idlelib/Icons/minusnode.gif
@@ -692,6 +697,27 @@
 %%PYTHON_LIBDIR%%/idlelib/idle.bat
 %%PYTHON_LIBDIR%%/idlelib/idle.py
 %%PYTHON_LIBDIR%%/idlelib/idle.pyw
+%%PYTHON_LIBDIR%%/idlelib/idle_test/README.txt
+%%PYTHON_LIBDIR%%/idlelib/idle_test/__init__.py
+%%PYTHON_LIBDIR%%/idlelib/idle_test/htest.py
+%%PYTHON_LIBDIR%%/idlelib/idle_test/mock_idle.py
+%%PYTHON_LIBDIR%%/idlelib/idle_test/mock_tk.py
+%%PYTHON_LIBDIR%%/idlelib/idle_test/test_autocomplete.py
+%%PYTHON_LIBDIR%%/idlelib/idle_test/test_autoexpand.py
+%%PYTHON_LIBDIR%%/idlelib/idle_test/test_calltips.py
+%%PYTHON_LIBDIR%%/idlelib/idle_test/test_config_name.py
+%%PYTHON_LIBDIR%%/idlelib/idle_test/test_delegator.py
+%%PYTHON_LIBDIR%%/idlelib/idle_test/test_formatparagraph.py
+%%PYTHON_LIBDIR%%/idlelib/idle_test/test_grep.py
+%%PYTHON_LIBDIR%%/idlelib/idle_test/test_hyperparser.py
+%%PYTHON_LIBDIR%%/idlelib/idle_test/test_idlehistory.py
+%%PYTHON_LIBDIR%%/idlelib/idle_test/test_parenmatch.py
+%%PYTHON_LIBDIR%%/idlelib/idle_test/test_pathbrowser.py
+%%PYTHON_LIBDIR%%/idlelib/idle_test/test_rstrip.py
+%%PYTHON_LIBDIR%%/idlelib/idle_test/test_searchengine.py
+%%PYTHON_LIBDIR%%/idlelib/idle_test/test_text.py
+%%PYTHON_LIBDIR%%/idlelib/idle_test/test_textview.py
+%%PYTHON_LIBDIR%%/idlelib/idle_test/test_warning.py
 %%PYTHON_LIBDIR%%/idlelib/idlever.py
 %%PYTHON_LIBDIR%%/idlelib/keybindingDialog.py
 %%PYTHON_LIBDIR%%/idlelib/macosxSupport.py
@@ -911,9 +937,14 @@
 %%PYTHON_LIBDIR%%/lib-tk/Tkinter.py
 %%PYTHON_LIBDIR%%/lib-tk/test/README
 %%PYTHON_LIBDIR%%/lib-tk/test/runtktests.py
+%%PYTHON_LIBDIR%%/lib-tk/test/widget_tests.py
 %%PYTHON_LIBDIR%%/lib-tk/test/test_tkinter/__init__.py
+%%PYTHON_LIBDIR%%/lib-tk/test/test_tkinter/test_geometry_managers.py
+%%PYTHON_LIBDIR%%/lib-tk/test/test_tkinter/test_images.py
 %%PYTHON_LIBDIR%%/lib-tk/test/test_tkinter/test_loadtk.py
 %%PYTHON_LIBDIR%%/lib-tk/test/test_tkinter/test_text.py
+%%PYTHON_LIBDIR%%/lib-tk/test/test_tkinter/test_variables.py
+%%PYTHON_LIBDIR%%/lib-tk/test/test_tkinter/test_widgets.py
 %%PYTHON_LIBDIR%%/lib-tk/test/test_ttk/__init__.py
 %%PYTHON_LIBDIR%%/lib-tk/test/test_ttk/support.py
 %%PYTHON_LIBDIR%%/lib-tk/test/test_ttk/test_extensions.py
@@ -976,18 +1007,8 @@
 %%PYTHON_LIBDIR%%/pickletools.py
 %%PYTHON_LIBDIR%%/pipes.py
 %%PYTHON_LIBDIR%%/pkgutil.py
-%%PYTHON_LIBDIR%%/plat-freebsd6/IN.py
-%%PYTHON_LIBDIR%%/plat-freebsd6/regen
-%%PYTHON_LIBDIR%%/plat-freebsd7/IN.py
-%%PYTHON_LIBDIR%%/plat-freebsd7/regen
-%%PYTHON_LIBDIR%%/plat-freebsd8/IN.py
-%%PYTHON_LIBDIR%%/plat-freebsd8/regen
-%%PYTHON_LIBDIR%%/plat-freebsd9/IN.py
-%%PYTHON_LIBDIR%%/plat-freebsd9/regen
-%%PYTHON_LIBDIR%%/plat-freebsd10/IN.py
-%%PYTHON_LIBDIR%%/plat-freebsd10/regen
-%%PYTHON_LIBDIR%%/plat-freebsd11/IN.py
-%%PYTHON_LIBDIR%%/plat-freebsd11/regen
+%%PYTHON_LIBDIR%%/plat-%%PYTHON_PLATFORM%%/IN.py
+%%PYTHON_LIBDIR%%/plat-%%PYTHON_PLATFORM%%/regen
 %%PYTHON_LIBDIR%%/platform.py
 %%PYTHON_LIBDIR%%/plistlib.py
 %%PYTHON_LIBDIR%%/popen2.py
@@ -1080,6 +1101,7 @@
 %%PYTHON_LIBDIR%%/test/autotest.py
 %%PYTHON_LIBDIR%%/test/bad_coding.py
 %%PYTHON_LIBDIR%%/test/bad_coding2.py
+%%PYTHON_LIBDIR%%/test/bad_coding3.py
 %%PYTHON_LIBDIR%%/test/badcert.pem
 %%PYTHON_LIBDIR%%/test/badkey.pem
 %%PYTHON_LIBDIR%%/test/badsyntax_future3.py
@@ -1281,6 +1303,17 @@
 %%PYTHON_LIBDIR%%/test/greyrgb.uue
 %%PYTHON_LIBDIR%%/test/https_svn_python_org_root.pem
 %%PYTHON_LIBDIR%%/test/ieee754.txt
+%%PYTHON_LIBDIR%%/test/imghdrdata/python.bmp
+%%PYTHON_LIBDIR%%/test/imghdrdata/python.gif
+%%PYTHON_LIBDIR%%/test/imghdrdata/python.jpg
+%%PYTHON_LIBDIR%%/test/imghdrdata/python.pbm
+%%PYTHON_LIBDIR%%/test/imghdrdata/python.pgm
+%%PYTHON_LIBDIR%%/test/imghdrdata/python.png
+%%PYTHON_LIBDIR%%/test/imghdrdata/python.ppm
+%%PYTHON_LIBDIR%%/test/imghdrdata/python.ras
+%%PYTHON_LIBDIR%%/test/imghdrdata/python.sgi
+%%PYTHON_LIBDIR%%/test/imghdrdata/python.tiff
+%%PYTHON_LIBDIR%%/test/imghdrdata/python.xbm
 %%PYTHON_LIBDIR%%/test/infinite_reload.py
 %%PYTHON_LIBDIR%%/test/inspect_fodder.py
 %%PYTHON_LIBDIR%%/test/inspect_fodder2.py
@@ -1498,6 +1531,7 @@
 %%PYTHON_LIBDIR%%/test/test_imageop.py
 %%PYTHON_LIBDIR%%/test/test_imaplib.py
 %%PYTHON_LIBDIR%%/test/test_imgfile.py
+%%PYTHON_LIBDIR%%/test/test_imghdr.py
 %%PYTHON_LIBDIR%%/test/test_imp.py
 %%PYTHON_LIBDIR%%/test/test_import.py
 %%PYTHON_LIBDIR%%/test/test_importhooks.py
@@ -1629,6 +1663,7 @@
 %%PYTHON_LIBDIR%%/test/test_socketserver.py
 %%PYTHON_LIBDIR%%/test/test_softspace.py
 %%PYTHON_LIBDIR%%/test/test_sort.py
+%%PYTHON_LIBDIR%%/test/test_spwd.py
 %%PYTHON_LIBDIR%%/test/test_sqlite.py
 %%PYTHON_LIBDIR%%/test/test_ssl.py
 %%PYTHON_LIBDIR%%/test/test_startfile.py
@@ -2393,6 +2428,7 @@
 @dirrm %%PYTHON_LIBDIR%%/test/cjkencodings
 @dirrm %%PYTHON_LIBDIR%%/test/data
 @dirrm %%PYTHON_LIBDIR%%/test/decimaltestdata
+@dirrm %%PYTHON_LIBDIR%%/test/imghdrdata
 @dirrm %%PYTHON_LIBDIR%%/test/subprocessdata
 @dirrm %%PYTHON_LIBDIR%%/test/tracedmodules
 @dirrm %%PYTHON_LIBDIR%%/test/xmltestdata
@@ -2401,12 +2437,7 @@
 @dirrm %%PYTHON_LIBDIR%%/sqlite3
 @dirrm %%PYTHON_LIBDIR%%/site-packages
 @dirrm %%PYTHON_LIBDIR%%/pydoc_data
-@dirrm %%PYTHON_LIBDIR%%/plat-freebsd11
-@dirrm %%PYTHON_LIBDIR%%/plat-freebsd10
-@dirrm %%PYTHON_LIBDIR%%/plat-freebsd9
-@dirrm %%PYTHON_LIBDIR%%/plat-freebsd8
-@dirrm %%PYTHON_LIBDIR%%/plat-freebsd7
-@dirrm %%PYTHON_LIBDIR%%/plat-freebsd6
+@dirrm %%PYTHON_LIBDIR%%/plat-%%PYTHON_PLATFORM%%
 @dirrm %%PYTHON_LIBDIR%%/multiprocessing/dummy
 @dirrm %%PYTHON_LIBDIR%%/multiprocessing
 @dirrm %%PYTHON_LIBDIR%%/logging
@@ -2425,6 +2456,7 @@
 @dirrm %%PYTHON_LIBDIR%%/importlib
 @dirrm %%PYTHON_LIBDIR%%/json/tests
 @dirrm %%PYTHON_LIBDIR%%/json
+@dirrm %%PYTHON_LIBDIR%%/idlelib/idle_test
 @dirrm %%PYTHON_LIBDIR%%/idlelib/Icons
 @dirrm %%PYTHON_LIBDIR%%/idlelib
 @dirrm %%PYTHON_LIBDIR%%/hotshot