From 61fd48d1a4a485f80045c2291f182066e4857652 Mon Sep 17 00:00:00 2001
From: Slavek Kabrda <bkabrda@redhat.com>
Date: Wed, 8 Jan 2014 10:01:56 +0100
Subject: [PATCH] Update to Python 3.4 beta 2.

- Refreshed patches: 55 (systemtap), 146 (hashlib-fips), 154 (test_gdb noise)
- Dropped patches: 114 (statvfs constants), 177 (platform unicode)
---
 00055-systemtap.patch                |  2 +-
 00114-statvfs-f_flag-constants.patch | 39 ---------------------------
 00146-hashlib-fips.patch             |  9 +++----
 00153-fix-test_gdb-noise.patch       |  4 +--
 00177-platform-unicode.patch         | 13 ---------
 python3.spec                         | 40 ++++++++++++++--------------
 6 files changed, 27 insertions(+), 80 deletions(-)
 delete mode 100644 00114-statvfs-f_flag-constants.patch
 delete mode 100644 00177-platform-unicode.patch

diff --git a/00055-systemtap.patch b/00055-systemtap.patch
index ddd5e77..3200c15 100644
--- a/00055-systemtap.patch
+++ b/00055-systemtap.patch
@@ -89,9 +89,9 @@ diff -up Python-3.3.0rc2/Doc/howto/index.rst.systemtap Python-3.3.0rc2/Doc/howto
 --- Python-3.3.0rc2/Doc/howto/index.rst.systemtap	2012-09-09 05:10:51.000000000 -0400
 +++ Python-3.3.0rc2/Doc/howto/index.rst	2012-09-10 09:17:21.117511779 -0400
 @@ -29,4 +29,5 @@ Currently, the HOWTOs are:
-    webservers.rst
     argparse.rst
     ipaddress.rst
+    clinic.rst
 +   instrumentation.rst
  
 diff -up Python-3.3.0rc2/Doc/howto/instrumentation.rst.systemtap Python-3.3.0rc2/Doc/howto/instrumentation.rst
diff --git a/00114-statvfs-f_flag-constants.patch b/00114-statvfs-f_flag-constants.patch
deleted file mode 100644
index ea99e08..0000000
--- a/00114-statvfs-f_flag-constants.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-diff -up Python-3.3.0b1/Modules/posixmodule.c.statvfs-f_flag-constants Python-3.3.0b1/Modules/posixmodule.c
---- Python-3.3.0b1/Modules/posixmodule.c.statvfs-f_flag-constants	2012-06-26 16:19:54.000000000 -0400
-+++ Python-3.3.0b1/Modules/posixmodule.c	2012-07-20 13:39:18.595546387 -0400
-@@ -11665,6 +11665,35 @@ all_ins(PyObject *d)
-     if (PyModule_AddIntMacro(m, ST_NOSUID)) return -1;
- #endif /* ST_NOSUID */
- 
-+    /* GNU extensions */
-+#ifdef ST_NODEV
-+    if (PyModule_AddIntMacro(m, ST_NODEV)) return -1;
-+#endif /* ST_NODEV */
-+#ifdef ST_NOEXEC
-+    if (PyModule_AddIntMacro(m, ST_NOEXEC)) return -1;
-+#endif /* ST_NOEXEC */
-+#ifdef ST_SYNCHRONOUS
-+    if (PyModule_AddIntMacro(m, ST_SYNCHRONOUS)) return -1;
-+#endif /* ST_SYNCHRONOUS */
-+#ifdef ST_MANDLOCK
-+    if (PyModule_AddIntMacro(m, ST_MANDLOCK)) return -1;
-+#endif /* ST_MANDLOCK */
-+#ifdef ST_WRITE
-+    if (PyModule_AddIntMacro(m, ST_WRITE)) return -1;
-+#endif /* ST_WRITE */
-+#ifdef ST_APPEND
-+    if (PyModule_AddIntMacro(m, ST_APPEND)) return -1;
-+#endif /* ST_APPEND */
-+#ifdef ST_NOATIME
-+    if (PyModule_AddIntMacro(m, ST_NOATIME)) return -1;
-+#endif /* ST_NOATIME */
-+#ifdef ST_NODIRATIME
-+    if (PyModule_AddIntMacro(m, ST_NODIRATIME)) return -1;
-+#endif /* ST_NODIRATIME */
-+#ifdef ST_RELATIME
-+    if (PyModule_AddIntMacro(m, ST_RELATIME)) return -1;
-+#endif /* ST_RELATIME */
-+
-     /* FreeBSD sendfile() constants */
- #ifdef SF_NODISKIO
-     if (PyModule_AddIntMacro(m, SF_NODISKIO)) return -1;
diff --git a/00146-hashlib-fips.patch b/00146-hashlib-fips.patch
index 7cd79ef..3d92c34 100644
--- a/00146-hashlib-fips.patch
+++ b/00146-hashlib-fips.patch
@@ -167,7 +167,7 @@
              constructors.add(_test_algorithm_via_hashlib_new)
  
          _hashlib = self._conditional_import_module('_hashlib')
-@@ -82,26 +107,13 @@
+@@ -82,26 +107,12 @@
              for algorithm, constructors in self.constructors_to_test.items():
                  constructor = getattr(_hashlib, 'openssl_'+algorithm, None)
                  if constructor:
@@ -192,10 +192,9 @@
 -        if _sha512:
 -            add_builtin_constructor('sha384')
 -            add_builtin_constructor('sha512')
-+        # TODO: remove this after sha3 is available through OpenSSL
-         _sha3 = self._conditional_import_module('_sha3')
-         if _sha3:
-             add_builtin_constructor('sha3_224')
+ 
+         super(HashLibTestCase, self).__init__(*args, **kwargs)
+ 
 @@ -157,9 +169,6 @@
              else:
                  del sys.modules['_md5']
diff --git a/00153-fix-test_gdb-noise.patch b/00153-fix-test_gdb-noise.patch
index 87c9396..8b0a76c 100644
--- a/00153-fix-test_gdb-noise.patch
+++ b/00153-fix-test_gdb-noise.patch
@@ -19,8 +19,8 @@
 --- Lib/test/test_gdb.py.old	2012-04-11 21:04:01.367073855 -0400
 +++ Lib/test/test_gdb.py	2012-04-12 08:52:58.320288761 -0400
 @@ -144,6 +153,10 @@
-             '"set sysroot"?',
-             'warning: Source file is more recent than executable.',
+             'Missing separate debuginfo for ',
+             'Try: zypper install -C ',
              )
 +        ignore_patterns += ('warning: Unable to open',
 +                            'Missing separate debuginfo for',
diff --git a/00177-platform-unicode.patch b/00177-platform-unicode.patch
deleted file mode 100644
index 7d847e1..0000000
--- a/00177-platform-unicode.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-Index: Python-3.3.0/Lib/platform.py
-===================================================================
---- Python-3.3.0.orig/Lib/platform.py
-+++ Python-3.3.0/Lib/platform.py
-@@ -331,7 +331,7 @@ def linux_distribution(distname='', vers
-         return _dist_try_harder(distname,version,id)
- 
-     # Read the first line
--    with open('/etc/'+file, 'r') as f:
-+    with open('/etc/'+file, 'r', encoding='utf-8', errors='surrogateescape') as f:
-         firstline = f.readline()
-     _distname, _version, _id = _parse_release_file(firstline)
- 
diff --git a/python3.spec b/python3.spec
index d53f8eb..2053757 100644
--- a/python3.spec
+++ b/python3.spec
@@ -8,7 +8,7 @@
 %global pyshortver 34
 
 # prereleasetag
-%global prerel b1
+%global prerel b2
 
 %global pylibdir %{_libdir}/python%{pybasever}
 %global dynload_dir %{pylibdir}/lib-dynload
@@ -53,7 +53,7 @@
 %global py_INSTSONAME_optimized libpython%{LDVERSION_optimized}.so.%{py_SOVERSION}
 %global py_INSTSONAME_debug     libpython%{LDVERSION_debug}.so.%{py_SOVERSION}
 
-%global with_debug_build 1
+%global with_debug_build 0
 
 %global with_gdb_hooks 1
 
@@ -266,10 +266,8 @@ Patch111: 00111-no-static-lib.patch
 Patch113: 00113-more-configuration-flags.patch
 
 # 00114 #
-# Add flags for statvfs.f_flag to the constant list in posixmodule (i.e. "os")
-# (rhbz:553020); partially upstream as http://bugs.python.org/issue7647
-# Not yet sent upstream
-Patch114: 00114-statvfs-f_flag-constants.patch
+# Upstream as of Python 3.4.0.b2
+#  Patch114: 00114-statvfs-f_flag-constants.patch
 
 # 00125 #
 # COUNT_ALLOCS is useful for debugging, but the upstream behaviour of always
@@ -381,9 +379,13 @@ Patch143: 00143-tsc-on-ppc.patch
 # - don't build the _md5 and _sha* modules; rely on the _hashlib implementation
 #   of hashlib
 # (rhbz#563986)
-# Note: for now we're using sha3 from Python tarball, not from OpenSSL, since
-# OpenSSL didn't implement it yet. When OpenSSL implements it again,
-# we will need to rm -rf Modules/_sha3 in prep and adapt the patch.
+# Note: Up to Python 3.4.0.b1, upstream had their own implementation of what
+# they assumed would become sha3. This patch was adapted to give it the
+# usedforsecurity argument, even though it did nothing (OpenSSL didn't have
+# sha3 implementation at that time).In 3.4.0.b2, sha3 implementation was reverted
+# (see http://bugs.python.org/issue16113), but the alterations were left in the
+# patch, since they may be useful again if upstream decides to rerevert sha3
+# implementation and OpenSSL still doesn't support it. For now, they're harmless.
 Patch146: 00146-hashlib-fips.patch
 
 # 00147 #
@@ -550,11 +552,8 @@ Patch173: 00173-workaround-ENOPROTOOPT-in-bind_port.patch
 #  Patch176: 00176-upstream-issue16754-so-extension.patch
 
 # 00177 #
-# Patch for potential unicode error when determining OS release names
-# http://bugs.python.org/issue17429
-# (rhbz#922149)
-# Does not affect python2 (python2 uses a byte string so it doesn't need to decode)
-Patch177: 00177-platform-unicode.patch
+# Fixed upstream as of Python 3.4.0.b2
+#  Patch177: 00177-platform-unicode.patch
 
 # 00178 #
 # Don't duplicate various FLAGS in sysconfig values
@@ -820,7 +819,7 @@ done
 %patch111 -p1
 # 112: not for python3
 %patch113 -p1
-%patch114 -p1
+# 00114: Upstream as of Python 3.4.0.b2
 
 %patch125 -p1 -b .less-verbose-COUNT_ALLOCS
 
@@ -879,7 +878,7 @@ done
 #00174: TODO
 # 00175: upstream as of Python 3.3.2
 # 00176: upstream as of Python 3.3.1
-%patch177 -p1
+# 00177: upstream as of Python 3.4.0.b2
 %patch178 -p1
 %patch179 -p1
 %patch180 -p1
@@ -1413,8 +1412,6 @@ rm -fr %{buildroot}
 %{dynload_dir}/_pickle.%{SOABI_optimized}.so
 %{dynload_dir}/_posixsubprocess.%{SOABI_optimized}.so
 %{dynload_dir}/_random.%{SOABI_optimized}.so
-# TODO: remove _sha3 when it reaches OpenSSL
-%{dynload_dir}/_sha3.%{SOABI_optimized}.so
 %{dynload_dir}/_socket.%{SOABI_optimized}.so
 %{dynload_dir}/_sqlite3.%{SOABI_optimized}.so
 %{dynload_dir}/_ssl.%{SOABI_optimized}.so
@@ -1681,8 +1678,6 @@ rm -fr %{buildroot}
 %{dynload_dir}/_pickle.%{SOABI_debug}.so
 %{dynload_dir}/_posixsubprocess.%{SOABI_debug}.so
 %{dynload_dir}/_random.%{SOABI_debug}.so
-# TODO: remove _sha3 when it reaches OpenSSL
-%{dynload_dir}/_sha3.%{SOABI_debug}.so
 %{dynload_dir}/_socket.%{SOABI_debug}.so
 %{dynload_dir}/_sqlite3.%{SOABI_debug}.so
 %{dynload_dir}/_ssl.%{SOABI_debug}.so
@@ -1760,6 +1755,11 @@ rm -fr %{buildroot}
 # ======================================================
 
 %changelog
+* Wed Jan 08 2014 Bohuslav Kabrda <bkabrda@redhat.com> - 3.4.0-0.1.b2
+- Update to Python 3.4 beta 2.
+- Refreshed patches: 55 (systemtap), 146 (hashlib-fips), 154 (test_gdb noise)
+- Dropped patches: 114 (statvfs constants), 177 (platform unicode)
+
 * Mon Nov 25 2013 Bohuslav Kabrda <bkabrda@redhat.com> - 3.4.0-0.1.b1
 - Update to Python 3.4 beta 1.
 - Refreshed patches: 102 (lib64), 111 (no static lib), 125 (less verbose COUNT