code:
The following patch, authored by Andreas Enge, looks for the flint include
files in the correct subdirectory.

diff -u -r python-flint-old/src/flint.pxd python-flint-new/src/flint.pxd
--- python-flint-old/src/flint.pxd	2019-03-19 10:26:11.055748626 +0100
+++ python-flint-new/src/flint.pxd	2019-03-19 10:35:23.269341203 +0100
@@ -27,7 +27,7 @@

 ctypedef long fmpz_struct

-cdef extern from "flint.h":
+cdef extern from "flint/flint.h":
     ctypedef void * flint_rand_t
     void flint_randinit(flint_rand_t state)
     void flint_randclear(flint_rand_t state)
@@ -35,7 +35,7 @@
     long flint_get_num_threads()
     void flint_cleanup()

-cdef extern from "nmod_vec.h":
+cdef extern from "flint/nmod_vec.h":
     ctypedef struct nmod_t:
        mp_limb_t n
        mp_limb_t ninv
@@ -47,7 +47,7 @@
     mp_limb_t nmod_mul(mp_limb_t a, mp_limb_t b, nmod_t mod)
     mp_limb_t nmod_div(mp_limb_t a, mp_limb_t b, nmod_t mod)

-cdef extern from "nmod_poly.h":
+cdef extern from "flint/nmod_poly.h":
     ctypedef struct nmod_poly_struct:
         mp_ptr coeffs
         long alloc
@@ -129,7 +129,7 @@
     void nmod_poly_factor_init(nmod_poly_factor_t fac)
     void nmod_poly_factor_clear(nmod_poly_factor_t fac)

-cdef extern from "nmod_mat.h":
+cdef extern from "flint/nmod_mat.h":
     ctypedef struct nmod_mat_struct:
         mp_limb_t * entries
         long r
@@ -178,7 +178,7 @@
     long nmod_mat_rref(nmod_mat_t A)
     long nmod_mat_nullspace(nmod_mat_t X, nmod_mat_t A)

-cdef extern from "fmpz.h":
+cdef extern from "flint/fmpz.h":
     ctypedef fmpz_struct fmpz_t[1]
     int COEFF_IS_MPZ(fmpz_struct v)
     void fmpz_init(fmpz_t op)
@@ -268,7 +268,7 @@
     void fmpz_rfac_uiui(fmpz_t r, ulong x, ulong n)
     void fmpz_primorial(fmpz_t res, ulong n)

-cdef extern from "fmpz_factor.h":
+cdef extern from "flint/fmpz_factor.h":
     ctypedef struct fmpz_factor_struct:
         int sign
         fmpz_struct * p
@@ -280,7 +280,7 @@
     void fmpz_factor_clear(fmpz_factor_t factor)
     void fmpz_factor(fmpz_factor_t factor, fmpz_t n)

-cdef extern from "fmpz_poly.h":
+cdef extern from "flint/fmpz_poly.h":
     ctypedef struct fmpz_poly_struct:
         fmpz_struct * coeffs
         long alloc
@@ -390,14 +390,14 @@
     void fmpz_poly_cos_minpoly(fmpz_poly_t, ulong)
     void fmpz_poly_swinnerton_dyer(fmpz_poly_t, ulong)

-cdef extern from "fmpz_poly_factor.h":
+cdef extern from "flint/fmpz_poly_factor.h":
     void fmpz_poly_factor_init(fmpz_poly_factor_t fac)
     void fmpz_poly_factor_clear(fmpz_poly_factor_t fac)
     void fmpz_poly_factor_zassenhaus(fmpz_poly_factor_t fac, fmpz_poly_t G)
     void fmpz_poly_factor(fmpz_poly_factor_t fac, fmpz_poly_t G)
     void fmpz_poly_factor_squarefree(fmpz_poly_factor_t fac, fmpz_poly_t G)

-cdef extern from "fmpz_mat.h":
+cdef extern from "flint/fmpz_mat.h":
     ctypedef struct fmpz_mat_struct:
         fmpz_struct * entries
         long r
@@ -448,7 +448,7 @@
     void fmpz_mat_snf(fmpz_mat_t S, const fmpz_mat_t A)
     int fmpz_mat_is_in_snf(const fmpz_mat_t A)

-cdef extern from "fmpz_lll.h":
+cdef extern from "flint/fmpz_lll.h":
     ctypedef struct fmpz_lll_struct:
         double delta
         double eta
@@ -461,7 +461,7 @@
     void fmpz_lll(fmpz_mat_t B, fmpz_mat_t U, const fmpz_lll_t fl)

-cdef extern from "fmpq.h":
+cdef extern from "flint/fmpq.h":
     ctypedef struct fmpq_struct:
         fmpz_struct num
         fmpz_struct den
@@ -506,7 +506,7 @@
     void fmpq_next_signed_minimal(fmpq_t res, fmpq_t x)
     void fmpq_harmonic_ui(fmpq_t res, ulong n)

-cdef extern from "fmpq_poly.h":
+cdef extern from "flint/fmpq_poly.h":
     ctypedef struct fmpq_poly_struct:
         fmpz_struct * coeffs
         fmpz_t den
@@ -620,7 +620,7 @@
     void fmpq_poly_compose_series(fmpq_poly_t res, fmpq_poly_t poly1, fmpq_poly_t poly2, long n)
     void fmpq_poly_revert_series(fmpq_poly_t res, fmpq_poly_t poly1, long n)

-cdef extern from "fmpq_mat.h":
+cdef extern from "flint/fmpq_mat.h":
     ctypedef struct fmpq_mat_struct:
         fmpq_struct * entries
         long r
@@ -672,7 +672,7 @@
     long fmpq_mat_rref(fmpq_mat_t B, fmpq_mat_t A)
     void fmpq_mat_transpose(fmpq_mat_t B, fmpq_mat_t A)

-cdef extern from "arith.h":
+cdef extern from "flint/arith.h":
     void arith_number_of_partitions(fmpz_t res, ulong n)
     int arith_moebius_mu(fmpz_t n)
     void arith_divisor_sigma(fmpz_t v, fmpz_t n, ulong k)


code:
Fix a test failure with recent versions of ... Pytest?  Python?

Taken from upstream:
https://github.com/keras-team/keras/commit/fe35050a8f18dc52304aa8da4e463eececa25240

diff --git a/tests/integration_tests/applications_test.py b/tests/integration_tests/applications_test.py
index 979f2f2abd6..6e3b57fa8e2 100644
--- a/tests/integration_tests/applications_test.py
+++ b/tests/integration_tests/applications_test.py
@@ -58,7 +58,8 @@ def _test_application_basic(app, last_dim=1000):
 def _test_application_notop(app, last_dim):
     output_shape = _get_output_shape(
         lambda: app(weights=None, include_top=False))
-    assert output_shape == (None, None, None, last_dim)
+    assert len(output_shape) == 4
+    assert output_shape[-1] == last_dim

 def test_mobilenet_v2_legacy_import():

repo_name: maximed/guix

license: mit


code:
This patch fixes a crash in the libxml2 bindings for Python 3.x
that 'itstool' stumbles upon when processing UTF-8 data:

  https://issues.guix.gnu.org/issue/37468

Patch by Jan Matejek
from <https://bugzilla.opensuse.org/show_bug.cgi?id=1065270>.

--- libxml2-2.9.5.orig/python/libxml.c
+++ libxml2-2.9.5/python/libxml.c
@@ -1620,6 +1620,7 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNU
     PyObject *message;
     PyObject *result;
     char str[1000];
+    unsigned char *ptr = (unsigned char *)str;

 #ifdef DEBUG_ERROR
     printf("libxml_xmlErrorFuncHandler(%p, %s, ...) called\n", ctx, msg);
@@ -1636,12 +1637,20 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNU
 	    str[999] = 0;
         va_end(ap);

+#if PY_MAJOR_VERSION >= 3
+        /* Ensure the error string doesn't start at UTF8 continuation. */
+        while (*ptr && (*ptr & 0xc0) == 0x80)
+            ptr++;
+#endif
+
         list = PyTuple_New(2);
         PyTuple_SetItem(list, 0, libxml_xmlPythonErrorFuncCtxt);
         Py_XINCREF(libxml_xmlPythonErrorFuncCtxt);
-        message = libxml_charPtrConstWrap(str);
+        message = libxml_charPtrConstWrap(ptr);
         PyTuple_SetItem(list, 1, message);
         result = PyEval_CallObject(libxml_xmlPythonErrorFuncHandler, list);
+        /* Forget any errors caused in the error handler. */
+        PyErr_Clear();
         Py_XDECREF(list);
         Py_XDECREF(result);
     }


code:
From: Tobias Geerinckx-Rice <me@tobias.gr>
Date: Tue, 02 Mar 2021 18:04:33 +0100
Subject: [PATCH] gnu: python-matplotlib: Run under Wayland with GTK3.

Adopted from upstream's fix[0] for
<https://github.com/matplotlib/matplotlib/issues/19405>.

[0]: https://github.com/liuyun88/matplotlib/commit/3d5000463bd23cb046681220f5511f07743f7d82

---
diff -Naur a/lib/matplotlib/backends/backend_gtk3.py b/lib/matplotlib/backends/backend_gtk3.py
--- a/lib/matplotlib/backends/backend_gtk3.py	2019-11-21 23:47:05.000000000 +0100
+++ b/lib/matplotlib/backends/backend_gtk3.py	2021-03-02 18:00:57.479929766 +0100
@@ -42,11 +42,12 @@

 try:
+    _display = Gdk.Display.get_default()
     cursord = {
-        cursors.MOVE          : Gdk.Cursor.new(Gdk.CursorType.FLEUR),
-        cursors.HAND          : Gdk.Cursor.new(Gdk.CursorType.HAND2),
-        cursors.POINTER       : Gdk.Cursor.new(Gdk.CursorType.LEFT_PTR),
-        cursors.SELECT_REGION : Gdk.Cursor.new(Gdk.CursorType.TCROSS),
-        cursors.WAIT          : Gdk.Cursor.new(Gdk.CursorType.WATCH),
+        cursors.MOVE          : Gdk.Cursor.new_from_name(_display, "move"),
+        cursors.HAND          : Gdk.Cursor.new_from_name(_display, "pointer"),
+        cursors.POINTER       : Gdk.Cursor.new_from_name(_display, "default"),
+        cursors.SELECT_REGION : Gdk.Cursor.new_from_name(_display, "crosshair"),
+        cursors.WAIT          : Gdk.Cursor.new_from_name(_display, "wait"),
     }
 except TypeError as exc:
     # Happens when running headless.  Convert to ImportError to cooperate with


code:
This patch has already been applied upstream, but is not included in the
current release 0.6.0.

From d2fc3b59f77c515b02dfe7ad936f89264375d2b4 Mon Sep 17 00:00:00 2001
From: Adrian Sampson <adrian@radbox.org>
Date: Wed, 29 Jul 2020 19:42:57 -0400
Subject: [PATCH] Fix test for WavPack bitrate

Fixes #34.
---
 docs/index.rst         | 5 +++++
 mediafile.py           | 2 +-
 test/test_mediafile.py | 2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/docs/index.rst b/docs/index.rst
index 7b622df..1465405 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -100,6 +100,11 @@ Internals
 Changelog
 ---------

+v0.7.0
+''''''
+
+- Mutagen 1.45.0 or later is now required.
+
 v0.6.0
 ''''''

diff --git a/mediafile.py b/mediafile.py
index 23fadaf..9e9d063 100644
--- a/mediafile.py
+++ b/mediafile.py
@@ -56,7 +56,7 @@
 import six

-__version__ = '0.6.0'
+__version__ = '0.7.0'
 __all__ = ['UnreadableFileError', 'FileTypeError', 'MediaFile']

 log = logging.getLogger(__name__)
diff --git a/test/test_mediafile.py b/test/test_mediafile.py
index e9e1850..7f17f44 100644
--- a/test/test_mediafile.py
+++ b/test/test_mediafile.py
@@ -907,7 +907,7 @@ class WavpackTest(ReadWriteTestBase, unittest.TestCase):
         'bitrate': 109312,
         'format': u'WavPack',
         'samplerate': 44100,
-        'bitdepth': 0,
+        'bitdepth': 16,
         'channels': 1,
     }


code:
Problem reported upstream:
https://github.com/linsomniac/python-memcached/issues/176

---
 memcache.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/memcache.py b/memcache.py
index 05b6657..b935681 100644
--- a/memcache.py
+++ b/memcache.py
@@ -1300,8 +1300,8 @@ class Client(threading.local):
             key = key[1]
         if key is None:
             raise Client.MemcachedKeyNoneError("Key is None")
-        if key is '':
-            if key_extra_len is 0:
+        if key == '':
+            if key_extra_len == 0:
                 raise Client.MemcachedKeyNoneError("Key is empty")

             #  key is empty but there is some other component to key
--
2.26.2


code:
Fix regex so that it works with Python 3.6.

See <https://docs.python.org/3/library/re.html#re.LOCALE>.

Copied from upstream bug report:
https://bugs.launchpad.net/python-mox3/+bug/1665266

From 05064cdb6ea7a16450c6beae2b6f7c6074212a69 Mon Sep 17 00:00:00 2001
From: Zac Medico <zmedico@gentoo.org>
Date: Thu, 16 Feb 2017 00:24:10 -0800
Subject: [PATCH] RegexTest: python3.6 compatibility

These fixes are backward-compatible with older python versions:

* raw strings fix invalid escape sequences
* flags=8 fixes ValueError: cannot use LOCALE flag with a str pattern
---
 mox3/tests/test_mox.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mox3/tests/test_mox.py b/mox3/tests/test_mox.py
index 15ac565..3a1af17 100644
--- a/mox3/tests/test_mox.py
+++ b/mox3/tests/test_mox.py
@@ -312,12 +312,12 @@ class RegexTest(testtools.TestCase):
     def testReprWithoutFlags(self):
         """repr should return the regular expression pattern."""
         self.assertTrue(
-            repr(mox.Regex(r"a\s+b")) == "<regular expression 'a\s+b'>")
+            repr(mox.Regex(r"a\s+b")) == r"<regular expression 'a\s+b'>")

     def testReprWithFlags(self):
         """repr should return the regular expression pattern and flags."""
-        self.assertTrue(repr(mox.Regex(r"a\s+b", flags=4)) ==
-                        "<regular expression 'a\s+b', flags=4>")
+        self.assertTrue(repr(mox.Regex(r"a\s+b", flags=8)) ==
+                        r"<regular expression 'a\s+b', flags=8>")

 class IsTest(testtools.TestCase):
--
2.10.2


code:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0aa9fda2..a573170c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -22,7 +22,7 @@ option(BUILD_ONNX_PYTHON "Build Python binaries" OFF)
 option(ONNX_GEN_PB_TYPE_STUBS "Generate protobuf python type stubs" ON)
 option(ONNX_WERROR "Build with Werror" OFF)
 option(ONNX_COVERAGE "Build with coverage instrumentation" OFF)
-option(ONNX_BUILD_TESTS "Build ONNX C++ APIs Tests" OFF)
+option(ONNX_BUILD_TESTS "Build ONNX C++ APIs Tests" ON)
 option(ONNX_USE_LITE_PROTO "Use lite protobuf instead of full." OFF)
 option(ONNXIFI_ENABLE_EXT "Enable onnxifi extensions." OFF)
 if(NOT DEFINED ONNX_ML)
@@ -82,8 +82,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL "AIX")
 endif()

 if(ONNX_BUILD_TESTS)
-  list(APPEND CMAKE_MODULE_PATH ${ONNX_ROOT}/cmake/external)
-  include(googletest)
+  find_package(GTest REQUIRED)
+  if(NOT GTest_FOUND)
+    message(FATAL_ERROR "cannot find googletest")
+  endif()
 endif()

 if((ONNX_USE_LITE_PROTO AND TARGET protobuf::libprotobuf-lite) OR ((NOT ONNX_USE_LITE_PROTO) AND TARGET protobuf::libprotobuf))
diff --git a/cmake/unittest.cmake b/cmake/unittest.cmake
index e29a93ff..ae146390 100644
--- a/cmake/unittest.cmake
+++ b/cmake/unittest.cmake
@@ -6,8 +6,8 @@ include(${ONNX_ROOT}/cmake/Utils.cmake)

 find_package(Threads)

-set(${UT_NAME}_libs ${googletest_STATIC_LIBRARIES})
-set(${ONNXIFI_TEST_DRIVER}_libs ${googletest_STATIC_LIBRARIES})
+set(${UT_NAME}_libs ${GTEST_LIBRARIES})
+set(${ONNXIFI_TEST_DRIVER}_libs ${GTEST_LIBRARIES})

 list(APPEND ${UT_NAME}_libs onnx)
 list(APPEND ${UT_NAME}_libs onnx_proto)
@@ -31,10 +31,10 @@ function(AddTest)
   list(REMOVE_DUPLICATES _UT_SOURCES)

   add_executable(${_UT_TARGET} ${_UT_SOURCES})
-  add_dependencies(${_UT_TARGET} onnx onnx_proto googletest)
+  add_dependencies(${_UT_TARGET} onnx onnx_proto)

   target_include_directories(${_UT_TARGET}
-                             PUBLIC ${googletest_INCLUDE_DIRS}
+                             PUBLIC ${GTEST_INCLUDE_DIRS}
                                     ${ONNX_INCLUDE_DIRS}
                                     ${PROTOBUF_INCLUDE_DIRS}
                                     ${ONNX_ROOT}


code:
Fix tests that are "hard coded" to expect x86_64 output by mocking the platform interface.

Submitted upstream:
https://github.com/pypa/packaging/pull/176

diff --git a/tests/test_tags.py b/tests/test_tags.py
index 1eacf68..0a3f1b4 100644
--- a/tests/test_tags.py
+++ b/tests/test_tags.py
@@ -435,37 +435,43 @@ class TestManylinuxPlatform:
         linux_platform = list(tags._linux_platforms(is_32bit=False))
         assert linux_platform == ["linux_x86_64"]

-    def test_linux_platforms_manylinux1(self, monkeypatch):
+    def test_linux_platforms_manylinux1(self, is_x86, monkeypatch):
         monkeypatch.setattr(
             tags, "_is_manylinux_compatible", lambda name, _: name == "manylinux1"
         )
-        if platform.system() != "Linux":
+        if platform.system() != "Linux" or not is_x86:
             monkeypatch.setattr(distutils.util, "get_platform", lambda: "linux_x86_64")
+            monkeypatch.setattr(platform, "machine", lambda: "x86_64")
         platforms = list(tags._linux_platforms(is_32bit=False))
-        assert platforms == ["manylinux1_x86_64", "linux_x86_64"]
+        arch = platform.machine()
+        assert platforms == ["manylinux1_" + arch, "linux_" + arch]

-    def test_linux_platforms_manylinux2010(self, monkeypatch):
+    def test_linux_platforms_manylinux2010(self, is_x86, monkeypatch):
         monkeypatch.setattr(
             tags, "_is_manylinux_compatible", lambda name, _: name == "manylinux2010"
         )
-        if platform.system() != "Linux":
+        if platform.system() != "Linux" or not is_x86:
             monkeypatch.setattr(distutils.util, "get_platform", lambda: "linux_x86_64")
+            monkeypatch.setattr(platform, "machine", lambda: "x86_64")
         platforms = list(tags._linux_platforms(is_32bit=False))
-        expected = ["manylinux2010_x86_64", "manylinux1_x86_64", "linux_x86_64"]
+        arch = platform.machine()
+        expected = ["manylinux2010_" + arch, "manylinux1_" + arch, "linux_" + arch]
         assert platforms == expected

-    def test_linux_platforms_manylinux2014(self, monkeypatch):
+    def test_linux_platforms_manylinux2014(self, is_x86, monkeypatch):
         monkeypatch.setattr(
             tags, "_is_manylinux_compatible", lambda name, _: name == "manylinux2014"
         )
-        if platform.system() != "Linux":
+        if platform.system() != "Linux" or not is_x86:
             monkeypatch.setattr(distutils.util, "get_platform", lambda: "linux_x86_64")
+            monkeypatch.setattr(platform, "machine", lambda: "x86_64")
         platforms = list(tags._linux_platforms(is_32bit=False))
+        arch = platform.machine()
         expected = [
-            "manylinux2014_x86_64",
-            "manylinux2010_x86_64",
-            "manylinux1_x86_64",
-            "linux_x86_64",
+            "manylinux2014_" + arch,
+            "manylinux2010_" + arch,
+            "manylinux1_" + arch,
+            "linux_" + arch,
         ]
         assert platforms == expected


code:
Remove this test to verify that things were modified since a certain time.

That assumption doesn't hold up when your environment doesn't have access to a
real clock and thinks it's living in 1970 :)

--- a/tests/test_fileapp.py    2015-04-23 13:48:37.000000000 -0700
+++ b/tests/test_fileapp.py	2016-02-22 19:20:08.332802417 -0800
@@ -223,8 +223,6 @@
                   status=304)
     res = app.get('/', headers={'If-None-Match': 'asdf'},
                   status=200)
-    res = app.get('/', headers={'If-Modified-Since': 'Sat, 1 Jan 2005 12:00:00 GMT'},
-                  status=200)
     res = app.get('/', headers={'If-Modified-Since': last_mod + '; length=100'},
                   status=304)
     res = app.get('/', headers={'If-Modified-Since': 'invalid date'},


code:
From 397463014fda3cdefe8d6c9d117ae16d878dc494 Mon Sep 17 00:00:00 2001
From: Michael Hudson-Doyle <michael.hudson@canonical.com>
Date: Tue, 25 Sep 2018 14:58:57 +1200
Subject: [PATCH] Keep compability with stdlib tokenize.py changes

https://github.com/python/cpython/commit/c4ef4896eac86a6759901c8546e26de4695a1389
is not yet part of any release of Python but has been backported to all
versions in Git (includeing 2.7!). It causes the tokenize.py module to
emit a synthetic NEWLINE token for files that do not in fact end with a
newline, which confuses pycodestyle's checks for blank lines at the end
of a file. Fortunately the synthetic NEWLINE tokens are easy to detect
(the token text is "").

Fixes #786
---
 pycodestyle.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pycodestyle.py b/pycodestyle.py
index 0d725d27..fbc3dca3 100755
--- a/pep8.py
+++ b/pep8.py
@@ -258,10 +258,10 @@ def trailing_blank_lines(physical_line, lines, line_number, total_lines):
     """
     if line_number == total_lines:
         stripped_last_line = physical_line.rstrip()
-        if not stripped_last_line:
+        if physical_line and not stripped_last_line:
             return 0, "W391 blank line at end of file"
         if stripped_last_line == physical_line:
-            return len(physical_line), "W292 no newline at end of file"
+            return len(lines[-1]), "W292 no newline at end of file"

 @register_check


code:
Fix CVE-2013-7459:

https://github.com/dlitz/pycrypto/issues/176
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2013-7459

Copied from Debian:

https://anonscm.debian.org/cgit/collab-maint/python-crypto.git/commit/?id=0de2243837ed369a086f15c50cca2be85bdfab9d

Debian adapts this upstream commit:

https://github.com/dlitz/pycrypto/commit/8dbe0dc3eea5c689d4f76b37b93fe216cf1f00d4

From 8dbe0dc3eea5c689d4f76b37b93fe216cf1f00d4 Mon Sep 17 00:00:00 2001
From: Legrandin <helderijs@gmail.com>
Date: Sun, 22 Dec 2013 22:24:46 +0100
Subject: [PATCH] Throw exception when IV is used with ECB or CTR

The IV parameter is currently ignored when initializing
a cipher in ECB or CTR mode.

For CTR mode, it is confusing: it takes some time to see
that a different parameter is needed (the counter).

For ECB mode, it is outright dangerous.

This patch forces an exception to be raised.
---
 lib/Crypto/SelfTest/Cipher/common.py | 31 +++++++++++++++++++++++--------
 src/block_template.c                 | 11 +++++++++++
 2 files changed, 34 insertions(+), 8 deletions(-)

--- a/lib/Crypto/SelfTest/Cipher/common.py
+++ b/lib/Crypto/SelfTest/Cipher/common.py
@@ -239,19 +239,34 @@ class RoundtripTest(unittest.TestCase):
         return """%s .decrypt() output of .encrypt() should not be garbled""" % (self.module_name,)

     def runTest(self):
-        for mode in (self.module.MODE_ECB, self.module.MODE_CBC, self.module.MODE_CFB, self.module.MODE_OFB, self.module.MODE_OPENPGP):
+
+        ## ECB mode
+        mode = self.module.MODE_ECB
+        encryption_cipher = self.module.new(a2b_hex(self.key), mode)
+        ciphertext = encryption_cipher.encrypt(self.plaintext)
+        decryption_cipher = self.module.new(a2b_hex(self.key), mode)
+        decrypted_plaintext = decryption_cipher.decrypt(ciphertext)
+        self.assertEqual(self.plaintext, decrypted_plaintext)
+
+        ## OPENPGP mode
+        mode = self.module.MODE_OPENPGP
+        encryption_cipher = self.module.new(a2b_hex(self.key), mode, self.iv)
+        eiv_ciphertext = encryption_cipher.encrypt(self.plaintext)
+        eiv = eiv_ciphertext[:self.module.block_size+2]
+        ciphertext = eiv_ciphertext[self.module.block_size+2:]
+        decryption_cipher = self.module.new(a2b_hex(self.key), mode, eiv)
+        decrypted_plaintext = decryption_cipher.decrypt(ciphertext)
+        self.assertEqual(self.plaintext, decrypted_plaintext)
+
+        ## All other non-AEAD modes (but CTR)
+        for mode in (self.module.MODE_CBC, self.module.MODE_CFB, self.module.MODE_OFB):
             encryption_cipher = self.module.new(a2b_hex(self.key), mode, self.iv)
             ciphertext = encryption_cipher.encrypt(self.plaintext)
-
-            if mode != self.module.MODE_OPENPGP:
-                decryption_cipher = self.module.new(a2b_hex(self.key), mode, self.iv)
-            else:
-                eiv = ciphertext[:self.module.block_size+2]
-                ciphertext = ciphertext[self.module.block_size+2:]
-                decryption_cipher = self.module.new(a2b_hex(self.key), mode, eiv)
+            decryption_cipher = self.module.new(a2b_hex(self.key), mode, self.iv)
             decrypted_plaintext = decryption_cipher.decrypt(ciphertext)
             self.assertEqual(self.plaintext, decrypted_plaintext)

+
 class PGPTest(unittest.TestCase):
     def __init__(self, module, params):
         unittest.TestCase.__init__(self)
--- a/src/block_template.c
+++ b/src/block_template.c
@@ -170,6 +170,17 @@ ALGnew(PyObject *self, PyObject *args, P
 				"Key cannot be the null string");
 		return NULL;
 	}
+	if (IVlen != 0 && mode == MODE_ECB)
+	{
+		PyErr_Format(PyExc_ValueError, "ECB mode does not use IV");
+		return NULL;
+	}
+	if (IVlen != 0 && mode == MODE_CTR)
+	{
+		PyErr_Format(PyExc_ValueError,
+			"CTR mode needs counter parameter, not IV");
+		return NULL;
+	}
 	if (IVlen != BLOCK_SIZE && mode != MODE_ECB && mode != MODE_CTR)
 	{
 		PyErr_Format(PyExc_ValueError,


code:
Drop use of the deprecated time.clock which was removed in Python 3.8.

Adapted from upstream pull request:

https://github.com/dlitz/pycrypto/pull/296

diff --git a/lib/Crypto/Random/_UserFriendlyRNG.py b/lib/Crypto/Random/_UserFriendlyRNG.py
--- a/lib/Crypto/Random/_UserFriendlyRNG.py
+++ b/lib/Crypto/Random/_UserFriendlyRNG.py
@@ -73,8 +73,11 @@ class _EntropyCollector(object):
         t = time.time()
         self._time_es.feed(struct.pack("@I", int(2**30 * (t - floor(t)))))

-        # Add the fractional part of time.clock()
-        t = time.clock()
+        # Add the fractional part of time.process_time()
+        try:
+           t = time.process_time()
+        except AttributeError:
+           t = time.clock()
         self._clock_es.feed(struct.pack("@I", int(2**30 * (t - floor(t)))))


code:
This patch is taken from the upstream repository
https://github.com/pydot/pydot/commit/a10ced4d132361027a545a471af4541dea8c5cf5.patch
It should be included in the 1.4.2 release.

From a10ced4d132361027a545a471af4541dea8c5cf5 Mon Sep 17 00:00:00 2001
From: Peter Nowee <peter@peternowee.com>
Date: Wed, 26 Jun 2019 15:43:38 +0800
Subject: [PATCH] Fix multi.dot Graphviz regression test

Commit d6602ad of 2018-12-01 fixed the regression test broken by commit
2d55978 of 2016-07-01. This revealed that `test/graphs/multi.dot` was
failing.

`multi.dot` was introduced in commit 2b3f088 of 2010-11-07 together
with many of the other tests still here today. It has not been touched
since. It is a DOT-file containing two digraphs. The regression test
compares the JPEG images rendered from the DOT-file by pydot with those
rendered by Graphviz's dot directly.

Commit 66734d2 of 2016-07-01 is the actual cause of the failure. It
changed one of the render methods of the regression test,
`_render_with_pydot`, from calculating a single hash for all the JPEG
images to calculating separate hashes for each JPEG image and then
concatenating those hashes in one long string. The other render method,
`_render_with_graphviz`, still calculates a single hash over all data.
For DOT-files that generate only one image the end result is the same,
but because `multi.dot` has two graphs, it produces two images and this
leads to comparing a string of two hashes with one single hash.

I do not think the change in generating the hash was intentional, for
the following reasons:
- Commit 66734d2 states that its purpose was to adapt the test to an
  API change in pydot. It does not mention a deliberate choice to
  change the testing method.
- There was no effort to change `_render_with_graphviz` to also produce
  multiple hashes.
- Except for easier debugging in case of a failing test with multiple
  images (AFAICT, only `multi.dot`), I do not see much added benefit in
  checking a concatenation of the hashes of all images vs. checking one
  hash of all images together: In both cases the test will fail if one
  or more images is rendered differently.
- Given that there were many commits authored that same hour, including
  commit 2d55978 which broke the regression tests, I suspect the author
  did not run the tests for each individual commit, but only at the end
  of that batch, and was therefore also not alerted of this change by
  the test suite.

Assuming that the change was not intended, this commit will now revert
`_render_with_pydot` to the old behavior of calculating a single hash
from all JPEG image data.

Tested with Debian 9.9, Graphviz 2.38.0-17, Python 2.7.13-2 and 3.5.3-1.

Fixes https://github.com/pydot/pydot/issues/204.
---
 test/pydot_unittest.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/test/pydot_unittest.py b/test/pydot_unittest.py
index 881ee16..64aa856 100644
--- a/test/pydot_unittest.py
+++ b/test/pydot_unittest.py
@@ -194,11 +194,11 @@ def _render_with_graphviz(self, filename, encoding):

     def _render_with_pydot(self, filename, encoding):
         c = pydot.graph_from_dot_file(filename, encoding=encoding)
-        sha = ''
+        jpe_data = bytearray()
         for g in c:
-            jpe_data = g.create(prog=TEST_PROGRAM, format='jpe', encoding=encoding)
-            sha += sha256(jpe_data).hexdigest()
-        return sha
+            jpe_data.extend(g.create(prog=TEST_PROGRAM, format='jpe',
+                                     encoding=encoding))
+        return sha256(jpe_data).hexdigest()

     def test_my_regression_tests(self):
         path = os.path.join(test_dir, TESTS_DIR_1)


code:
This test incorrectly assumes that the root user is always available.
However, in the build environment, the root user is not available.
Note that because the original file distributed in the release on PyPi
has lines ending in CRLF, those are retained in the diff below.

--- a/pyfakefs/tests/fake_filesystem_test.py	1969-12-31 16:00:00.000000000 -0800
+++ b/pyfakefs/tests/fake_filesystem_test.py	1969-12-31 16:00:00.000000000 -0800
@@ -1021,15 +1021,6 @@
             self.assertEqual(self.path.expanduser('~'),
                              self.os.environ['HOME'].replace('/', '!'))

-    @unittest.skipIf(TestCase.is_windows or TestCase.is_cygwin,
-                     'only tested on unix systems')
-    def test_expand_root(self):
-        if sys.platform == 'darwin':
-            roothome = '!var!root'
-        else:
-            roothome = '!root'
-        self.assertEqual(self.path.expanduser('~root'), roothome)
-
     def test_getsize_path_nonexistent(self):
         file_path = 'foo!bar!baz'
         self.assertRaises(os.error, self.path.getsize, file_path)


code:
Fix test failure of test_XXX caused by upgrade of gpgme from 1.6.0 to
1.8.0:

======================================================================
FAIL: test_encrypt_to_signonly (tests.test_encrypt_decrypt.EncryptDecryptTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/guix-build-python2-pygpgme-0.3.drv-0/pygpgme-0.3/tests/test_encrypt_decrypt.py", line 185, in test_encrypt_to_signonly
    self.assertEqual(exc.args[0], gpgme.ERR_SOURCE_UNKNOWN)
AssertionError: 7 != 0

----------------------------------------------------------------------

Patch copied from the Debian package pygpgme-0.3-1.2:

https://sources.debian.net/src/pygpgme/0.3-1.2/debian/patches/0005-Fix-test-failures-with-pinentry.patch/

From: "Dr. Tobias Quathamer" <toddy@debian.org>
Date: Thu, 24 Nov 2016 12:20:54 +0100
Subject: Fix test failures with pinentry

---
 tests/test_encrypt_decrypt.py | 5 +++--
 tests/test_passphrase.py      | 2 ++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/tests/test_encrypt_decrypt.py b/tests/test_encrypt_decrypt.py
index 21ae83e..05707e1 100644
--- a/tests/test_encrypt_decrypt.py
+++ b/tests/test_encrypt_decrypt.py
@@ -132,6 +132,7 @@ class EncryptDecryptTestCase(GpgHomeTestCase):
             os.write(fd, b'Symmetric passphrase\n')
         ctx = gpgme.Context()
         ctx.armor = True
+        ctx.pinentry_mode = gpgme.PINENTRY_MODE_LOOPBACK
         ctx.passphrase_cb = passphrase
         ctx.encrypt(None, 0, plaintext, ciphertext)
         self.assertTrue(
@@ -182,8 +183,8 @@ class EncryptDecryptTestCase(GpgHomeTestCase):
             ctx.encrypt([recipient], gpgme.ENCRYPT_ALWAYS_TRUST,
                         plaintext, ciphertext)
         except gpgme.GpgmeError as exc:
-            self.assertEqual(exc.args[0], gpgme.ERR_SOURCE_UNKNOWN)
-            self.assertEqual(exc.args[1], gpgme.ERR_GENERAL)
+            self.assertEqual(exc.args[0], gpgme.ERR_SOURCE_GPGME)
+            self.assertEqual(exc.args[1], gpgme.ERR_UNUSABLE_PUBKEY)
         else:
             self.fail('gpgme.GpgmeError not raised')

diff --git a/tests/test_passphrase.py b/tests/test_passphrase.py
index 35b3c59..05e6811 100644
--- a/tests/test_passphrase.py
+++ b/tests/test_passphrase.py
@@ -34,6 +34,7 @@ class PassphraseTestCase(GpgHomeTestCase):
         ctx = gpgme.Context()
         key = ctx.get_key('EFB052B4230BBBC51914BCBB54DCBBC8DBFB9EB3')
         ctx.signers = [key]
+        ctx.pinentry_mode = gpgme.PINENTRY_MODE_LOOPBACK
         plaintext = BytesIO(b'Hello World\n')
         signature = BytesIO()

@@ -55,6 +56,7 @@ class PassphraseTestCase(GpgHomeTestCase):
         ctx = gpgme.Context()
         key = ctx.get_key('EFB052B4230BBBC51914BCBB54DCBBC8DBFB9EB3')
         ctx.signers = [key]
+        ctx.pinentry_mode = gpgme.PINENTRY_MODE_LOOPBACK
         ctx.passphrase_cb = self.passphrase_cb
         plaintext = BytesIO(b'Hello World\n')
         signature = BytesIO()


code:
From 3cc41c05fad5601c0dd1832f64a6e9efca017727 Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Date: Mon, 1 Apr 2019 11:36:04 -0400
Subject: [PATCH] robottime: Honor the SOURCE_DATE_EPOCH environment variable.

Honoring the SOURCE_DATE_EPOCH environment variable allows building
the documentation using libdoc reproducibly, by setting the generated
timestamp to a fixed value.

For more background on reproducible builds and the SOURCE_DATE_EPOCH
environment variable, see:
https://reproducible-builds.org/specs/source-date-epoch/.

* src/robot/utils/robottime.py: import `os'.
(TimestampCache._get_epoch): Retrieve date from SOURCE_DATE_EPOCH if
it is defined, otherwise from time.time().
* utest/output/test_logger.py (TestLogger.test_write_to_one_logger):
Check for the existance of a timestamp attribute instead of checking
for its content as the later is easy to break when using the
SOURCE_DATE_EPOCH environment variable.
---
 src/robot/utils/robottime.py | 3 +++
 utest/output/test_logger.py  | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/robot/utils/robottime.py b/src/robot/utils/robottime.py
index 06432a4a6..91526f826 100644
--- a/src/robot/utils/robottime.py
+++ b/src/robot/utils/robottime.py
@@ -14,6 +14,7 @@
 #  limitations under the License.

 import datetime
+import os
 import time
 import re

@@ -395,6 +396,8 @@ class TimestampCache(object):

     # Seam for mocking
     def _get_epoch(self):
+        if os.getenv('SOURCE_DATE_EPOCH'):
+            return float(os.getenv('SOURCE_DATE_EPOCH'))
         return time.time()

     def _use_cache(self, secs, *separators):
diff --git a/utest/output/test_logger.py b/utest/output/test_logger.py
index 92fe6d77d..e980227aa 100644
--- a/utest/output/test_logger.py
+++ b/utest/output/test_logger.py
@@ -46,7 +46,7 @@ class TestLogger(unittest.TestCase):
         logger = LoggerMock(('Hello, world!', 'INFO'))
         self.logger.register_logger(logger)
         self.logger.write('Hello, world!', 'INFO')
-        assert_true(logger.msg.timestamp.startswith('20'))
+        assert_true(hasattr(logger.msg, 'timestamp'))

     def test_write_to_one_logger_with_trace_level(self):
         logger = LoggerMock(('expected message', 'TRACE'))
--
2.20.1


code:
This patch is an excerpt of this upstream commit:

  commit 0a24478a550132f1882e5be5f5dbc0fc446a8a6c
  Author: Michael Waskom <mwaskom@users.noreply.github.com>
  Date:   Mon Dec 21 18:44:58 2020 -0500

      Raise minimal supported Python to 3.7 and bump requirements (#2396)

It fixes the failure of 'test_weights'.

--- a/seaborn/tests/test_distributions.py
+++ b/seaborn/tests/test_distributions.py
@@ -709,21 +708,17 @@ class TestKDEPlotUnivariate:
         integral = integrate.trapz(ydata, np.log10(xdata))
         assert integral == pytest.approx(1)

-    @pytest.mark.skipif(
-        LooseVersion(scipy.__version__) < "1.2.0",
-        reason="Weights require scipy >= 1.2.0"
-    )
     def test_weights(self):

         x = [1, 2]
         weights = [2, 1]

-        ax = kdeplot(x=x, weights=weights)
+        ax = kdeplot(x=x, weights=weights, bw_method=.1)

         xdata, ydata = ax.lines[0].get_xydata().T

-        y1 = ydata[np.argwhere(np.abs(xdata - 1).min())]
-        y2 = ydata[np.argwhere(np.abs(xdata - 2).min())]
+        y1 = ydata[np.abs(xdata - 1).argmin()]
+        y2 = ydata[np.abs(xdata - 2).argmin()]

         assert y1 == pytest.approx(2 * y2)


code:
https://github.com/testing-cabal/testtools/commit/29004731f9c480b7c44a9c2605513d50d372898f.patch
Should be fixed in the next release

From 29004731f9c480b7c44a9c2605513d50d372898f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
Date: Thu, 17 May 2018 17:52:26 +0200
Subject: [PATCH] Fix the tests on Python 3.7

Exception's repr got changed not to include trailing comma

Fixes https://github.com/testing-cabal/testtools/issues/270
---
 .travis.yml                                |  1 +
 testtools/tests/matchers/test_exception.py | 11 +++++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 7f1f4db7..784608e0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,6 +5,7 @@ python:
   - "3.4"
   - "3.5"
   - "3.6"
+  - "3.7-dev"
   - "pypy"

 install:
diff --git a/testtools/tests/matchers/test_exception.py b/testtools/tests/matchers/test_exception.py
index 6cd80af1..acd39252 100644
--- a/testtools/tests/matchers/test_exception.py
+++ b/testtools/tests/matchers/test_exception.py
@@ -32,15 +32,22 @@ class TestMatchesExceptionInstanceInterface(TestCase, TestMatchersInterface):
     matches_matches = [error_foo]
     matches_mismatches = [error_bar, error_base_foo]

+    if sys.version_info >= (3, 7):
+        # exception's repr has changed
+        _e = ''
+    else:
+        _e = ','
+
     str_examples = [
-        ("MatchesException(Exception('foo',))",
+        ("MatchesException(Exception('foo'%s))" % _e,
          MatchesException(Exception('foo')))
         ]
     describe_examples = [
         ("%r is not a %r" % (Exception, ValueError),
          error_base_foo,
          MatchesException(ValueError("foo"))),
-        ("ValueError('bar',) has different arguments to ValueError('foo',).",
+        ("ValueError('bar'%s) has different arguments to ValueError('foo'%s)."
+         % (_e, _e),
          error_bar,
          MatchesException(ValueError("foo"))),
         ]


code:
Skip tests that fail with newer versions of Python.

Patch copied from Gentoo:

https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-python/unittest2/files/unittest2-1.1.0-python3.5-test.patch

diff --git a/unittest2/test/test_loader.py b/unittest2/test/test_loader.py
index 683f662..347eea5 100644
--- a/unittest2/test/test_loader.py
+++ b/unittest2/test/test_loader.py
@@ -509,6 +509,7 @@ class Test_TestLoader(unittest2.TestCase):
     #
     # What happens when an impossible name is given, relative to the provided
     # `module`?
+    @unittest.skipIf(sys.version_info[:2] >= (3, 5), "python 3.5 has problems here")
     def test_loadTestsFromName__relative_malformed_name(self):
         loader = unittest.TestLoader()

@@ -811,6 +812,7 @@ class Test_TestLoader(unittest2.TestCase):
     # TestCase or TestSuite instance."
     #
     # What happens when presented with an impossible module name?
+    @unittest.skipIf(sys.version_info[:2] >= (3, 5), "python 3.5 has problems here")
     def test_loadTestsFromNames__malformed_name(self):
         loader = unittest2.TestLoader()

@@ -918,6 +920,7 @@ class Test_TestLoader(unittest2.TestCase):
     # "The method optionally resolves name relative to the given module"
     #
     # What happens when presented with an impossible attribute name?
+    @unittest.skipIf(sys.version_info[:2] >= (3, 5), "python 3.5 has problems here")
     def test_loadTestsFromNames__relative_malformed_name(self):
         loader = unittest.TestLoader()


code:
--- a/setup.py	2017-09-12 01:22:06.273997788 +0200
+++ b/setup.py	2017-09-12 01:22:14.297918757 +0200
@@ -57,7 +57,7 @@
 # Both install and setup requires - because we read VERSION from within the
 # package, and the package also exports all the APIs.
 # six for compat helpers
-REQUIRES = ['argparse', 'six>=1.4', 'traceback2'],
+REQUIRES = ['six>=1.4', 'traceback2'],

 params = dict(
     name=NAME,


code:
Skip test that requires getaddrinfo(), which is not available in the build
environment.  This package uses a regexp for finding tests (see runner.py),
so using @unittest.skip does not work.

--- a/waitress/tests/test_adjustments.py
+++ b/waitress/tests/test_adjustments.py
@@ -185,22 +185,6 @@
     def test_bad_port(self):
         self.assertRaises(ValueError, self._makeOne, listen='127.0.0.1:test')

-    def test_service_port(self):
-        if WIN and PY2: # pragma: no cover
-            # On Windows and Python 2 this is broken, so we raise a ValueError
-            self.assertRaises(
-                ValueError,
-                self._makeOne,
-                listen='127.0.0.1:http',
-            )
-            return
-
-        inst = self._makeOne(listen='127.0.0.1:http 0.0.0.0:https')
-
-        bind_pairs = [sockaddr[:2] for (_, _, _, sockaddr) in inst.listen]
-
-        self.assertEqual(bind_pairs, [('127.0.0.1', 80), ('0.0.0.0', 443)])
-
     def test_dont_mix_host_port_listen(self):
         self.assertRaises(
             ValueError,


code:
From ca548da9ba78ddee90779051210e3e89185e4f7d Mon Sep 17 00:00:00 2001
From: Michel Alexandre Salim <michel@michel-slm.name>
Date: Mon, 15 Feb 2016 23:03:42 +0700
Subject: coverage-4.0a6 compatibility

coverage 4.0a6 no longer generates .coverage file, so use -f when
deleting .coverage to ensure deletion does not fail.
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'Makefile')

diff --git a/Makefile b/Makefile
index 7818f57..362c07f 100644
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,7 @@ fsck-larch.1: fsck-larch.1.in fsck-larch

 check:
 	python -m CoverageTestRunner --ignore-missing-from=without-tests
-	rm .coverage
+	rm -f .coverage
 	./insert-remove-test tempdir 100
 	rm -r tempdir larch.log
 	cmdtest tests
--
cgit v1.1


code:
Skip unicode docstring test, required when running on Python 2.

See <https://github.com/wolever/parameterized/issues/44>.

--- a/parameterized/test.py
+++ b/parameterized/test.py
@@ -284,11 +284,6 @@
             "        More" %(foo, )
         )

-    @parameterized.expand([param("foo")])
-    def test_unicode_docstring(self, foo):
-        u"""Döcumentation."""
-        self._assert_docstring(u"Döcumentation [with foo=%r]." %(foo, ))
-
     @parameterized.expand([param("foo", )])
     def test_default_values_get_correct_value(self, foo, bar=12):
         """Documentation"""


code:
From e5df32ffbf37481dbb6a70c4d4e7b7b9778c5549 Mon Sep 17 00:00:00 2001
From: "John (J5) Palmieri" <johnp@redhat.com>
Date: Sat, 13 Aug 2011 04:13:28 -0400
Subject: remove references to deprecated GI_INFO_TYPE_ERROR_DOMAIN

diff --git a/gi/pygi-info.c b/gi/pygi-info.c
index 8729e25..007b609 100644
--- a/gi/pygi-info.c
+++ b/gi/pygi-info.c
@@ -165,9 +165,6 @@ _pygi_info_new (GIBaseInfo *info)
         case GI_INFO_TYPE_CONSTANT:
             type = &PyGIConstantInfo_Type;
             break;
-        case GI_INFO_TYPE_ERROR_DOMAIN:
-            type = &PyGIErrorDomainInfo_Type;
-            break;
         case GI_INFO_TYPE_UNION:
             type = &PyGIUnionInfo_Type;
             break;
@@ -484,7 +481,6 @@ _pygi_g_type_info_size (GITypeInfo *type_info)
                 case GI_INFO_TYPE_INVALID:
                 case GI_INFO_TYPE_FUNCTION:
                 case GI_INFO_TYPE_CONSTANT:
-                case GI_INFO_TYPE_ERROR_DOMAIN:
                 case GI_INFO_TYPE_VALUE:
                 case GI_INFO_TYPE_SIGNAL:
                 case GI_INFO_TYPE_PROPERTY:
@@ -863,7 +859,6 @@ pygi_g_struct_info_is_simple (GIStructInfo *struct_info)
                     case GI_INFO_TYPE_INVALID:
                     case GI_INFO_TYPE_FUNCTION:
                     case GI_INFO_TYPE_CONSTANT:
-                    case GI_INFO_TYPE_ERROR_DOMAIN:
                     case GI_INFO_TYPE_VALUE:
                     case GI_INFO_TYPE_SIGNAL:
                     case GI_INFO_TYPE_PROPERTY:
--
cgit v0.10.1


code:
This test tries to send a KeyboardInterrupt, which does
not work in the build environment.

--- a/test_subprocess32.py	2017-03-06 22:21:49.334045485 +0100
+++ b/test_subprocess32.py	2017-03-06 22:22:02.490439949 +0100
@@ -1299,12 +1299,6 @@
         getattr(p, method)(*args)
         return p

-    def test_send_signal(self):
-        p = self._kill_process('send_signal', signal.SIGINT)
-        _, stderr = p.communicate()
-        self.assertIn('KeyboardInterrupt', stderr)
-        self.assertNotEqual(p.wait(), 0)
-
     def test_kill(self):
         p = self._kill_process('kill')
         _, stderr = p.communicate()


code:
From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <SRS0=i+5i=HB=nongnu.org=qemu-devel-bounces+qemu-devel=archiver.kernel.org@kernel.org>
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
	aws-us-west-2-korg-lkml-1.web.codeaurora.org
X-Spam-Level:
X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_INVALID,
	DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH,
	MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY,
	URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0
Received: from mail.kernel.org (mail.kernel.org [198.145.29.99])
	by smtp.lore.kernel.org (Postfix) with ESMTP id 87556C433E0
	for <qemu-devel@archiver.kernel.org>; Sat, 30 Jan 2021 13:20:40 +0000 (UTC)
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by mail.kernel.org (Postfix) with ESMTPS id EF26964DE1
	for <qemu-devel@archiver.kernel.org>; Sat, 30 Jan 2021 13:20:39 +0000 (UTC)
DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF26964DE1
Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com
Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org
Received: from localhost ([::1]:42488 helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org>)
	id 1l5qB3-0008CX-02
	for qemu-devel@archiver.kernel.org; Sat, 30 Jan 2021 08:20:37 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:45174)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ppandit@redhat.com>)
 id 1l5q9q-0007ld-1c
 for qemu-devel@nongnu.org; Sat, 30 Jan 2021 08:19:22 -0500
Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:42898)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256)
 (Exim 4.90_1) (envelope-from <ppandit@redhat.com>)
 id 1l5q9k-0007Ia-TV
 for qemu-devel@nongnu.org; Sat, 30 Jan 2021 08:19:21 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;
 s=mimecast20190719; t=1612012753;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding;
 bh=7vu4z8M+bFjhFzEuAYsQG4i3APx7aMqv7tFxRRO5+8Q=;
 b=egCsTdgVBnRlHnVN84HsSpNOUl/NkqEnGuv9rRdG2AZ1Fee5ZatpJm5zJ7YUW2HvzB4rtO
 EaDIKaN1wzf/yHf0CsJ60TPGG3DqQSC/EsTSr2l/GNGq4prDYTXVrS3rXFu9ofByUVvzwU
 q9Iy1X1Bh3S21m7jXY0AYx4Tu9Ikq9w=
Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com
 [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id
 us-mta-588-1JF7mzMfP1KpRpNKj4cAWQ-1; Sat, 30 Jan 2021 08:19:08 -0500
X-MC-Unique: 1JF7mzMfP1KpRpNKj4cAWQ-1
Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com
 [10.5.11.22])
 (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
 (No client certificate requested)
 by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8F0F439380;
 Sat, 30 Jan 2021 13:19:07 +0000 (UTC)
Received: from localhost.localdomain (unknown [10.33.36.2])
 by smtp.corp.redhat.com (Postfix) with ESMTPS id 17D581002C11;
 Sat, 30 Jan 2021 13:19:04 +0000 (UTC)
From: P J P <ppandit@redhat.com>
To: Dmitry Fleytman <dmitry.fleytman@gmail.com>
Subject: [PATCH] net: vmxnet3: validate configuration values during activate
 (CVE-2021-20203)
Date: Sat, 30 Jan 2021 18:46:52 +0530
Message-Id: <20210130131652.954143-1-ppandit@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22
Authentication-Results: relay.mimecast.com;
 auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ppandit@redhat.com
X-Mimecast-Spam-Score: 0
X-Mimecast-Originator: redhat.com
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="US-ASCII"
Received-SPF: pass client-ip=63.128.21.124; envelope-from=ppandit@redhat.com;
 helo=us-smtp-delivery-124.mimecast.com
X-Spam_score_int: -30
X-Spam_score: -3.1
X-Spam_bar: ---
X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.255,
 DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.23
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: Gaoning Pan <pgn@zju.edu.cn>, QEMU Developers <qemu-devel@nongnu.org>,
 Prasad J Pandit <pjp@fedoraproject.org>
Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org
Sender: "Qemu-devel"
 <qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org>
Archived-At: <https://lore.kernel.org/qemu-devel/20210130131652.954143-1-ppandit@redhat.com/>
List-Archive: <https://lore.kernel.org/qemu-devel/>

From: Prasad J Pandit <pjp@fedoraproject.org>

While activating device in vmxnet3_acticate_device(), it does not
validate guest supplied configuration values against predefined
minimum - maximum limits. This may lead to integer overflow or
OOB access issues. Add checks to avoid it.

Fixes: CVE-2021-20203
Buglink: https://bugs.launchpad.net/qemu/+bug/1913873
Reported-by: Gaoning Pan <pgn@zju.edu.cn>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
---
 hw/net/vmxnet3.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index eff299f629..4a910ca971 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -1420,6 +1420,7 @@ static void vmxnet3_activate_device(VMXNET3State *s)
     vmxnet3_setup_rx_filtering(s);
     /* Cache fields from shared memory */
     s->mtu = VMXNET3_READ_DRV_SHARED32(d, s->drv_shmem, devRead.misc.mtu);
+    assert(VMXNET3_MIN_MTU <= s->mtu && s->mtu < VMXNET3_MAX_MTU);
     VMW_CFPRN("MTU is %u", s->mtu);

     s->max_rx_frags =
@@ -1473,6 +1474,9 @@ static void vmxnet3_activate_device(VMXNET3State *s)
         /* Read rings memory locations for TX queues */
         pa = VMXNET3_READ_TX_QUEUE_DESCR64(d, qdescr_pa, conf.txRingBasePA);
         size = VMXNET3_READ_TX_QUEUE_DESCR32(d, qdescr_pa, conf.txRingSize);
+        if (size > VMXNET3_TX_RING_MAX_SIZE) {
+            size = VMXNET3_TX_RING_MAX_SIZE;
+        }

         vmxnet3_ring_init(d, &s->txq_descr[i].tx_ring, pa, size,
                           sizeof(struct Vmxnet3_TxDesc), false);
@@ -1483,6 +1487,9 @@ static void vmxnet3_activate_device(VMXNET3State *s)
         /* TXC ring */
         pa = VMXNET3_READ_TX_QUEUE_DESCR64(d, qdescr_pa, conf.compRingBasePA);
         size = VMXNET3_READ_TX_QUEUE_DESCR32(d, qdescr_pa, conf.compRingSize);
+        if (size > VMXNET3_TC_RING_MAX_SIZE) {
+            size = VMXNET3_TC_RING_MAX_SIZE;
+        }
         vmxnet3_ring_init(d, &s->txq_descr[i].comp_ring, pa, size,
                           sizeof(struct Vmxnet3_TxCompDesc), true);
         VMXNET3_RING_DUMP(VMW_CFPRN, "TXC", i, &s->txq_descr[i].comp_ring);
@@ -1524,6 +1531,9 @@ static void vmxnet3_activate_device(VMXNET3State *s)
             /* RX rings */
             pa = VMXNET3_READ_RX_QUEUE_DESCR64(d, qd_pa, conf.rxRingBasePA[j]);
             size = VMXNET3_READ_RX_QUEUE_DESCR32(d, qd_pa, conf.rxRingSize[j]);
+            if (size > VMXNET3_RX_RING_MAX_SIZE) {
+                size = VMXNET3_RX_RING_MAX_SIZE;
+            }
             vmxnet3_ring_init(d, &s->rxq_descr[i].rx_ring[j], pa, size,
                               sizeof(struct Vmxnet3_RxDesc), false);
             VMW_CFPRN("RX queue %d:%d: Base: %" PRIx64 ", Size: %d",
@@ -1533,6 +1543,9 @@ static void vmxnet3_activate_device(VMXNET3State *s)
         /* RXC ring */
         pa = VMXNET3_READ_RX_QUEUE_DESCR64(d, qd_pa, conf.compRingBasePA);
         size = VMXNET3_READ_RX_QUEUE_DESCR32(d, qd_pa, conf.compRingSize);
+        if (size > VMXNET3_RC_RING_MAX_SIZE) {
+            size = VMXNET3_RC_RING_MAX_SIZE;
+        }
         vmxnet3_ring_init(d, &s->rxq_descr[i].comp_ring, pa, size,
                           sizeof(struct Vmxnet3_RxCompDesc), true);
         VMW_CFPRN("RXC queue %d: Base: %" PRIx64 ", Size: %d", i, pa, size);
--
2.29.2


code:
From 2793f47c066ed396b38893c10533202fceb1a05f Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Date: Thu, 17 Sep 2020 13:28:19 -0400
Subject: [PATCH] build: Build and install a Texinfo version of the manual.

Take advantage of the Sphinx texinfo backend to generate a QEMU info
manual.  The Texinfo format allows for more structure and info readers
provide more advanced navigation capabilities compared to manpages
readers.

* configure (infodir): Add an --infodir option, which allows
configuring the directory under which the info manuals are installed.
* docs/meson.build (texi, info): New targets.

Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>

diff --git a/configure b/configure
--- a/configure
+++ b/configure
@@ -951,6 +951,8 @@ for opt do
     static="yes"
     QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
   ;;
+  --infodir=*) infodir="$optarg"
+  ;;
   --mandir=*) mandir="$optarg"
   ;;
   --bindir=*) bindir="$optarg"
@@ -978,7 +980,7 @@ for opt do
   --host=*|--build=*|\
   --disable-dependency-tracking|\
   --sbindir=*|--sharedstatedir=*|\
-  --oldincludedir=*|--datarootdir=*|--infodir=*|\
+  --oldincludedir=*|--datarootdir=*|\
   --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
     # These switches are silently ignored, for compatibility with
     # autoconf-generated configure scripts. This allows QEMU's
@@ -1599,6 +1601,7 @@ else
 fi
 mandir="${mandir:-$prefix/share/man}"
 datadir="${datadir:-$prefix/share}"
+infodir="${infodir:-$datadir/info}"
 docdir="${docdir:-$prefix/share/doc}"
 sysconfdir="${sysconfdir:-$prefix/etc}"
 local_statedir="${local_statedir:-$prefix/var}"
@@ -1736,6 +1739,7 @@ Advanced options (experts only):
   --with-git-submodules=validate fail if git submodules are not up to date
   --with-git-submodules=ignore   do not update or check git submodules (default if no .git dir)
   --static                 enable static build [$static]
+  --infodir=PATH           install info manual in PATH
   --mandir=PATH            install man pages in PATH
   --datadir=PATH           install firmware in PATH/$qemu_suffix
   --localedir=PATH         install translation in PATH/$qemu_suffix
diff --git a/docs/meson.build b/docs/meson.build
--- a/docs/meson.build
+++ b/docs/meson.build
@@ -104,4 +104,25 @@ if build_docs
   alias_target('sphinxdocs', sphinxdocs)
   alias_target('html', sphinxdocs)
   alias_target('man', sphinxmans)
+
+  # Generate a Texinfo version of the QEMU manual.
+  makeinfo = find_program(['texi2any', 'makeinfo'])
+  if makeinfo.found()
+    sphinxtexi = custom_target(
+      'QEMU manual generated texinfo source',
+      output: ['QEMU.texi', 'sphinxtexi.stamp'],
+      depfile: 'sphinxtexi.d',
+      command: [SPHINX_ARGS, '-Ddepfile=@DEPFILE@',
+               '-Ddepfile_stamp=@OUTPUT1@', '-b', 'texinfo',
+               meson.current_source_dir(), meson.current_build_dir()])
+    sphinxinfo = custom_target(
+      'QEMU info manual',
+      input: sphinxtexi,
+      output: 'QEMU.info',
+      install: true,
+      install_dir: get_option('infodir'),
+      command: [makeinfo, '--no-split', '@INPUT0@', '--output=@OUTPUT@'])
+    alias_target('texi', sphinxtexi)
+    alias_target('info', sphinxinfo)
+  endif
 endif
diff --git a/meson.build b/meson.build
--- a/meson.build
+++ b/meson.build
@@ -35,6 +35,7 @@ endif
 qemu_confdir = get_option('sysconfdir') / get_option('qemu_suffix')
 qemu_datadir = get_option('datadir') / get_option('qemu_suffix')
 qemu_docdir = get_option('docdir') / get_option('qemu_suffix')
+qemu_infodir = get_option('infodir') / get_option('qemu_suffix')
 qemu_moddir = get_option('libdir') / get_option('qemu_suffix')

 qemu_desktopdir = get_option('datadir') / 'applications'
@@ -2433,6 +2434,7 @@ else
   summary_info += {'local state directory': 'queried at runtime'}
 endif
 summary_info += {'Doc directory':     get_option('docdir')}
+summary_info += {'Info directory':    get_option('infodir')}
 summary_info += {'Build directory':   meson.current_build_dir()}
 summary_info += {'Source path':       meson.current_source_dir()}
 summary_info += {'GIT submodules':    config_host['GIT_SUBMODULES']}


code:
From 75e5b70e6b5dcc4f2219992d7cffa462aa406af0 Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <pbonzini@redhat.com>
Date: Tue, 28 Nov 2017 11:51:27 +0100
Subject: [PATCH] memfd: fix configure test
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit

Recent glibc added memfd_create in sys/mman.h.  This conflicts with
the definition in util/memfd.c:

    /builddir/build/BUILD/qemu-2.11.0-rc1/util/memfd.c:40:12: error: static declaration of memfd_create follows non-static declaration

Fix the configure test, and remove the sys/memfd.h inclusion since the
file actually does not exist---it is a typo in the memfd_create(2) man
page.

Cc: Marc-AndrÃ© Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 configure    | 2 +-
 util/memfd.c | 4 +---
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/configure b/configure
index 9c8aa5a..99ccc17 100755
--- a/configure
+++ b/configure
@@ -3923,7 +3923,7 @@ fi
 # check if memfd is supported
 memfd=no
 cat > $TMPC << EOF
-#include <sys/memfd.h>
+#include <sys/mman.h>

 int main(void)
 {
diff --git a/util/memfd.c b/util/memfd.c
index 4571d1a..412e94a 100644
--- a/util/memfd.c
+++ b/util/memfd.c
@@ -31,9 +31,7 @@

 #include "qemu/memfd.h"

-#ifdef CONFIG_MEMFD
-#include <sys/memfd.h>
-#elif defined CONFIG_LINUX
+#if defined CONFIG_LINUX && !defined CONFIG_MEMFD
 #include <sys/syscall.h>
 #include <asm/unistd.h>

--
1.8.3.1


code:
This patch was taken from NixOS
https://raw.githubusercontent.com/Mindavi/nixpkgs/1a737743a829746e48f4869ac517ff29c23c9d09/pkgs/tools/security/afl/qemu-patches/syscall-glibc2_30.diff
It is based on an unmerged patch against american-fuzzy-lop and was
never merged upstream because the author was unable to sign Google's CLA.
Based on https://github.com/google/AFL/commit/6c917e3d63a2a0685d58c3518524f9615b001893.patch

--- qemu-2.10.0-clean/linux-user/syscall.c	2020-03-12 18:47:47.898592169 +0100
+++ qemu-2.10.0/linux-user/syscall.c	2020-03-13 09:13:42.461809699 +0100
@@ -34,6 +34,7 @@
 #include <sys/resource.h>
 #include <sys/swap.h>
 #include <linux/capability.h>
+#include <linux/sockios.h> // https://lkml.org/lkml/2019/6/3/988
 #include <sched.h>
 #include <sys/timex.h>
 #ifdef __ia64__
@@ -256,7 +257,9 @@ static type name (type1 arg1,type2 arg2,
 #endif

 #ifdef __NR_gettid
-_syscall0(int, gettid)
+// taken from https://patchwork.kernel.org/patch/10862231/
+#define __NR_sys_gettid __NR_gettid
+_syscall0(int, sys_gettid)
 #else
 /* This is a replacement for the host gettid() and must return a host
    errno. */
@@ -6219,7 +6222,7 @@ static void *clone_func(void *arg)
     cpu = ENV_GET_CPU(env);
     thread_cpu = cpu;
     ts = (TaskState *)cpu->opaque;
-    info->tid = gettid();
+    info->tid = sys_gettid();
     task_settid(ts);
     if (info->child_tidptr)
         put_user_u32(info->tid, info->child_tidptr);
@@ -6363,9 +6366,9 @@ static int do_fork(CPUArchState *env, un
                mapping.  We can't repeat the spinlock hack used above because
                the child process gets its own copy of the lock.  */
             if (flags & CLONE_CHILD_SETTID)
-                put_user_u32(gettid(), child_tidptr);
+                put_user_u32(sys_gettid(), child_tidptr);
             if (flags & CLONE_PARENT_SETTID)
-                put_user_u32(gettid(), parent_tidptr);
+                put_user_u32(sys_gettid(), parent_tidptr);
             ts = (TaskState *)cpu->opaque;
             if (flags & CLONE_SETTLS)
                 cpu_set_tls (env, newtls);
@@ -11402,7 +11405,7 @@ abi_long do_syscall(void *cpu_env, int n
         break;
 #endif
     case TARGET_NR_gettid:
-        ret = get_errno(gettid());
+        ret = get_errno(sys_gettid());
         break;
 #ifdef TARGET_NR_readahead
     case TARGET_NR_readahead:


code:
Fix a build failure that occurs with newer versions of Meson when
gdbus-codegen is unavailable.

Taken from upstream:
https://gitlab.com/qemu-project/qemu/-/commit/5ecfb76ccc056eb6127e44268e475827ae73b9e0

diff --git a/configure b/configure
--- a/configure
+++ b/configure
@@ -3341,7 +3341,7 @@ if ! test "$gio" = "no"; then
         gio_cflags=$($pkg_config --cflags gio-2.0)
         gio_libs=$($pkg_config --libs gio-2.0)
         gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0)
-        if [ ! -x "$gdbus_codegen" ]; then
+        if ! has "$gdbus_codegen"; then
             gdbus_codegen=
         fi
         # Check that the libraries actually work -- Ubuntu 18.04 ships
@@ -5704,6 +5704,8 @@ if test "$gio" = "yes" ; then
     echo "CONFIG_GIO=y" >> $config_host_mak
     echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
     echo "GIO_LIBS=$gio_libs" >> $config_host_mak
+fi
+if test "$gdbus_codegen" != "" ; then
     echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak
 fi
 echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak


code:
Prevent Sphinx 4 and later from creating subdirectories, which
the build scripts are not equipped to deal with.

Taken from upstream:
https://gitlab.com/qemu-project/qemu/-/issues/256
https://gitlab.com/qemu-project/qemu/-/commit/269a7e97865cb863c9ca19e5f2e6a40ac9eddf82

diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -279,6 +279,7 @@
      ['Stefan Hajnoczi <stefanha@redhat.com>',
       'Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>'], 1),
 ]
+man_make_section_directory = False

 # -- Options for Texinfo output -------------------------------------------


code:
Fix compatibility with Qt 5.15.

Patch copied from upstream source repository:

https://bazaar.launchpad.net/~adamreichold/qpdfview/trunk/revision/2104

--- a/sources/model.h	2017-04-19 21:01:25 +0000
+++ b/sources/model.h	2020-06-09 06:24:11 +0000
@@ -24,6 +24,7 @@
 #define DOCUMENTMODEL_H

 #include <QList>
+#include <QPainterPath>
 #include <QtPlugin>
 #include <QWidget>
 #include <QVector>


code:
Make the library installable. Patch copied from pull request:

https://github.com/nayuki/QR-Code-generator/pull/72

From 1625fc1665e1f83eb73c0f5670dcfda96dc0b3e4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= <tchvatal@suse.com>
Date: Tue, 3 Dec 2019 11:57:24 +0100
Subject: [PATCH 1/7] Do not append to C/XX/FLAGS but just set them if not
 defined already

---
 c/Makefile   | 2 +-
 cpp/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/c/Makefile b/c/Makefile
index fd0c367..b27449c 100644
--- a/c/Makefile
+++ b/c/Makefile
@@ -29,7 +29,7 @@
 # - CFLAGS: Any extra user-specified compiler flags (can be blank).

 # Recommended compiler flags:
-CFLAGS += -std=c99 -O
+CFLAGS ?= -std=c99 -O

 # Extra flags for diagnostics:
 # CFLAGS += -g -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -fsanitize=undefined,address
diff --git a/cpp/Makefile b/cpp/Makefile
index f83c512..666f976 100644
--- a/cpp/Makefile
+++ b/cpp/Makefile
@@ -29,7 +29,7 @@
 # - CXXFLAGS: Any extra user-specified compiler flags (can be blank).

 # Recommended compiler flags:
-CXXFLAGS += -std=c++11 -O
+CXXFLAGS ?= -std=c++11 -O

 # Extra flags for diagnostics:
 # CXXFLAGS += -g -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -fsanitize=undefined,address

From 2e496a0f59d5c6782c1e3e2a3ca36d0272b384f3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= <tchvatal@suse.com>
Date: Tue, 3 Dec 2019 11:59:59 +0100
Subject: [PATCH 2/7] Make use of -fPIC parameter when building'

---
 c/Makefile   | 2 +-
 cpp/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/c/Makefile b/c/Makefile
index b27449c..bf79462 100644
--- a/c/Makefile
+++ b/c/Makefile
@@ -77,7 +77,7 @@ $(LIBFILE): $(LIBOBJ)

 # Object files
 %.o: %.c .deps/timestamp
-	$(CC) $(CFLAGS) -c -o $@ -MMD -MF .deps/$*.d $<
+	$(CC) $(CFLAGS) -fPIC -c -o $@ -MMD -MF .deps/$*.d $<

 # Have a place to store header dependencies automatically generated by compiler
 .deps/timestamp:
diff --git a/cpp/Makefile b/cpp/Makefile
index 666f976..f37cf66 100644
--- a/cpp/Makefile
+++ b/cpp/Makefile
@@ -73,7 +73,7 @@ $(LIBFILE): $(LIBOBJ)

 # Object files
 %.o: %.cpp .deps/timestamp
-	$(CXX) $(CXXFLAGS) -c -o $@ -MMD -MF .deps/$*.d $<
+	$(CXX) $(CXXFLAGS) -fPIC -c -o $@ -MMD -MF .deps/$*.d $<

 # Have a place to store header dependencies automatically generated by compiler
 .deps/timestamp:

From 29489faaa5a3b014c5c2d95ca34033df470de73c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= <tchvatal@suse.com>
Date: Tue, 3 Dec 2019 12:07:19 +0100
Subject: [PATCH 3/7] Generate both shared and static libraries

---
 c/Makefile   | 14 ++++++++++----
 cpp/Makefile | 14 ++++++++++----
 2 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/c/Makefile b/c/Makefile
index bf79462..38eda2d 100644
--- a/c/Makefile
+++ b/c/Makefile
@@ -51,16 +51,19 @@ CFLAGS ?= -std=c99 -O
 # ---- Targets to build ----

 LIB = qrcodegen
-LIBFILE = lib$(LIB).a
+ARFILE = lib$(LIB).a
+LIBFILE = lib$(LIB).so
+# Bump the soname number when the ABI changes and gets incompatible
+SO_NAME = $(LIBFILE).1
 LIBOBJ = qrcodegen.o
 MAINS = qrcodegen-demo qrcodegen-test qrcodegen-worker

 # Build all binaries
-all: $(LIBFILE) $(MAINS)
+all: $(LIBFILE) $(ARFILE) $(MAINS)

 # Delete build output
 clean:
-	rm -f -- $(LIBOBJ) $(LIBFILE) $(MAINS:=.o) $(MAINS)
+	rm -f -- $(LIBOBJ) $(LIBFILE) $(ARFILE) $(MAINS:=.o) $(MAINS)
 	rm -rf .deps

 # Executable files
@@ -72,9 +75,12 @@ qrcodegen-test: qrcodegen-test.c $(LIBOBJ:%.o=%.c)
 	$(CC) $(CFLAGS) -DQRCODEGEN_TEST -o $@ $^

 # The library
-$(LIBFILE): $(LIBOBJ)
+$(ARFILE): $(LIBOBJ)
 	$(AR) -crs $@ -- $^

+$(LIBFILE): $(LIBOBJ)
+	$(CC) -shared -Wl,-soname,$(SO_NAME) $(LDFLAGS) -o $@ $^
+
 # Object files
 %.o: %.c .deps/timestamp
 	$(CC) $(CFLAGS) -fPIC -c -o $@ -MMD -MF .deps/$*.d $<
diff --git a/cpp/Makefile b/cpp/Makefile
index f37cf66..606cdad 100644
--- a/cpp/Makefile
+++ b/cpp/Makefile
@@ -51,16 +51,19 @@ CXXFLAGS ?= -std=c++11 -O
 # ---- Targets to build ----

 LIB = qrcodegen
-LIBFILE = lib$(LIB).a
+ARFILE = lib$(LIB).a
+LIBFILE = lib$(LIB).so
+# Bump the soname number when the ABI changes and gets incompatible
+SO_NAME = $(LIBFILE).1
 LIBOBJ = QrCode.o
 MAINS = QrCodeGeneratorDemo QrCodeGeneratorWorker

 # Build all binaries
-all: $(LIBFILE) $(MAINS)
+all: $(LIBFILE) $(ARFILE) $(MAINS)

 # Delete build output
 clean:
-	rm -f -- $(LIBOBJ) $(LIBFILE) $(MAINS:=.o) $(MAINS)
+	rm -f -- $(LIBOBJ) $(LIBFILE) $(ARFILE) $(MAINS:=.o) $(MAINS)
 	rm -rf .deps

 # Executable files
@@ -68,9 +71,12 @@ clean:
 	$(CXX) $(CXXFLAGS) -o $@ $< -L . -l $(LIB)

 # The library
-$(LIBFILE): $(LIBOBJ)
+$(ARFILE): $(LIBOBJ)
 	$(AR) -crs $@ -- $^

+$(LIBFILE): $(LIBOBJ)
+	$(CC) -shared -Wl,-soname,$(SO_NAME) $(LDFLAGS) -o $@ $^
+
 # Object files
 %.o: %.cpp .deps/timestamp
 	$(CXX) $(CXXFLAGS) -fPIC -c -o $@ -MMD -MF .deps/$*.d $<

From 064f38d6a8dc0a457728a47ee4ca1e927e46d5ec Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= <tchvatal@suse.com>
Date: Tue, 3 Dec 2019 12:45:34 +0100
Subject: [PATCH 4/7] Create install targets for C and CPP

---
 c/Makefile   | 26 ++++++++++++++++++++++++++
 cpp/Makefile | 27 +++++++++++++++++++++++++++
 2 files changed, 53 insertions(+)

diff --git a/c/Makefile b/c/Makefile
index 38eda2d..7521944 100644
--- a/c/Makefile
+++ b/c/Makefile
@@ -34,6 +34,8 @@ CFLAGS ?= -std=c99 -O
 # Extra flags for diagnostics:
 # CFLAGS += -g -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -fsanitize=undefined,address

+# Version information
+VERSION = 1.5.0

 # ---- Controlling make ----

@@ -55,9 +57,15 @@ ARFILE = lib$(LIB).a
 LIBFILE = lib$(LIB).so
 # Bump the soname number when the ABI changes and gets incompatible
 SO_NAME = $(LIBFILE).1
+REAL_NAME = $(LIBFILE).$(VERSION)
+HEADERS = qrcodegen.h
 LIBOBJ = qrcodegen.o
 MAINS = qrcodegen-demo qrcodegen-test qrcodegen-worker

+# define paths to install
+INCLUDEDIR ?= $(DESTDIR)/usr/include/qrcodegen
+LIBDIR ?= $(DESTDIR)/usr/lib
+
 # Build all binaries
 all: $(LIBFILE) $(ARFILE) $(MAINS)

@@ -66,6 +74,24 @@ clean:
 	rm -f -- $(LIBOBJ) $(LIBFILE) $(ARFILE) $(MAINS:=.o) $(MAINS)
 	rm -rf .deps

+install-shared: $(LIBFILE)
+	install -d $(LIBDIR) || true
+	install -m 0644 $(LIBFILE) $(LIBDIR)/$(REAL_NAME)
+	rm -f $(LIBDIR)/$(SO_NAME)
+	ln -s $(REAL_NAME) $(LIBDIR)/$(SO_NAME)
+	rm -f $(LIBDIR)/$(LIBFILE)
+	ln -s $(SO_NAME) $(LIBDIR)/$(LIBFILE)
+
+install-static: $(ARFILE)
+	install -d $(LIBDIR) || true
+	install -m 0644 $(ARFILE) $(LIBDIR)/$(ARFILE)
+
+install-header: $(HEADERS)
+	install -d $(INCLUDEDIR) || true
+	install -m 0644 $(HEADERS) $(INCLUDEDIR)/
+
+install: install-shared install-static install-header
+
 # Executable files
 %: %.o $(LIBFILE)
 	$(CC) $(CFLAGS) -o $@ $< -L . -l $(LIB)
diff --git a/cpp/Makefile b/cpp/Makefile
index 606cdad..3271bd8 100644
--- a/cpp/Makefile
+++ b/cpp/Makefile
@@ -34,6 +34,8 @@ CXXFLAGS ?= -std=c++11 -O
 # Extra flags for diagnostics:
 # CXXFLAGS += -g -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -fsanitize=undefined,address

+# Version information
+VERSION = 1.5.0

 # ---- Controlling make ----

@@ -55,9 +57,16 @@ ARFILE = lib$(LIB).a
 LIBFILE = lib$(LIB).so
 # Bump the soname number when the ABI changes and gets incompatible
 SO_NAME = $(LIBFILE).1
+REAL_NAME = $(LIBFILE).$(VERSION)
+HEADERS = QrCode.hpp
 LIBOBJ = QrCode.o
 MAINS = QrCodeGeneratorDemo QrCodeGeneratorWorker

+# define paths to install
+INCLUDEDIR ?= $(DESTDIR)/usr/include/qrcodegen
+LIBDIR ?= $(DESTDIR)/usr/lib
+
+
 # Build all binaries
 all: $(LIBFILE) $(ARFILE) $(MAINS)

@@ -66,6 +75,24 @@ clean:
 	rm -f -- $(LIBOBJ) $(LIBFILE) $(ARFILE) $(MAINS:=.o) $(MAINS)
 	rm -rf .deps

+install-shared: $(LIBFILE)
+	install -d $(LIBDIR) || true
+	install -m 0644 $(LIBFILE) $(LIBDIR)/$(REAL_NAME)
+	rm -f $(LIBDIR)/$(SO_NAME)
+	ln -s $(REAL_NAME) $(LIBDIR)/$(SO_NAME)
+	rm -f $(LIBDIR)/$(LIBFILE)
+	ln -s $(SO_NAME) $(LIBDIR)/$(LIBFILE)
+
+install-static: $(ARFILE)
+	install -d $(LIBDIR) || true
+	install -m 0644 $(ARFILE) $(LIBDIR)/$(ARFILE)
+
+install-header: $(HEADERS)
+	install -d $(INCLUDEDIR) || true
+	install -m 0644 $(HEADERS) $(INCLUDEDIR)/
+
+install: install-shared install-static install-header
+
 # Executable files
 %: %.o $(LIBFILE)
 	$(CXX) $(CXXFLAGS) -o $@ $< -L . -l $(LIB)

From a635ff4654f94ab26b458c46a8841543e5bc8c67 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= <tchvatal@suse.com>
Date: Tue, 3 Dec 2019 12:50:39 +0100
Subject: [PATCH 5/7] Rename cpp library to qrcodegencpp to avoid conflict

---
 cpp/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cpp/Makefile b/cpp/Makefile
index 3271bd8..42fa4ff 100644
--- a/cpp/Makefile
+++ b/cpp/Makefile
@@ -52,7 +52,7 @@ VERSION = 1.5.0

 # ---- Targets to build ----

-LIB = qrcodegen
+LIB = qrcodegencpp
 ARFILE = lib$(LIB).a
 LIBFILE = lib$(LIB).so
 # Bump the soname number when the ABI changes and gets incompatible

From c073e7dfad6454dfd725a69c347f8272d29ea41c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= <tchvatal@suse.com>
Date: Tue, 7 Jan 2020 09:18:59 +0100
Subject: [PATCH 6/7] Add PREFIX variable and few minor fixes from code review

---
 c/Makefile   | 9 +++++----
 cpp/Makefile | 9 +++++----
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/c/Makefile b/c/Makefile
index 7521944..874933e 100644
--- a/c/Makefile
+++ b/c/Makefile
@@ -29,7 +29,7 @@
 # - CFLAGS: Any extra user-specified compiler flags (can be blank).

 # Recommended compiler flags:
-CFLAGS ?= -std=c99 -O
+CFLAGS += -std=c99

 # Extra flags for diagnostics:
 # CFLAGS += -g -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -fsanitize=undefined,address
@@ -63,8 +63,9 @@ LIBOBJ = qrcodegen.o
 MAINS = qrcodegen-demo qrcodegen-test qrcodegen-worker

 # define paths to install
-INCLUDEDIR ?= $(DESTDIR)/usr/include/qrcodegen
-LIBDIR ?= $(DESTDIR)/usr/lib
+PREFIX ?= /usr/local
+INCLUDEDIR ?= $(DESTDIR)$(PREFIX)/include/qrcodegen
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib

 # Build all binaries
 all: $(LIBFILE) $(ARFILE) $(MAINS)
@@ -105,7 +106,7 @@ $(ARFILE): $(LIBOBJ)
 	$(AR) -crs $@ -- $^

 $(LIBFILE): $(LIBOBJ)
-	$(CC) -shared -Wl,-soname,$(SO_NAME) $(LDFLAGS) -o $@ $^
+	$(CC) $(CFLAGS) -shared -Wl,-soname,$(SO_NAME) $(LDFLAGS) -o $@ $^

 # Object files
 %.o: %.c .deps/timestamp
diff --git a/cpp/Makefile b/cpp/Makefile
index 42fa4ff..f8d9b7f 100644
--- a/cpp/Makefile
+++ b/cpp/Makefile
@@ -29,7 +29,7 @@
 # - CXXFLAGS: Any extra user-specified compiler flags (can be blank).

 # Recommended compiler flags:
-CXXFLAGS ?= -std=c++11 -O
+CXXFLAGS += -std=c++11

 # Extra flags for diagnostics:
 # CXXFLAGS += -g -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -fsanitize=undefined,address
@@ -63,8 +63,9 @@ LIBOBJ = QrCode.o
 MAINS = QrCodeGeneratorDemo QrCodeGeneratorWorker

 # define paths to install
-INCLUDEDIR ?= $(DESTDIR)/usr/include/qrcodegen
-LIBDIR ?= $(DESTDIR)/usr/lib
+PREFIX ?= /usr/local
+INCLUDEDIR ?= $(DESTDIR)$(PREFIX)/include/qrcodegen
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib

 # Build all binaries
@@ -102,7 +103,7 @@ $(ARFILE): $(LIBOBJ)
 	$(AR) -crs $@ -- $^

 $(LIBFILE): $(LIBOBJ)
-	$(CC) -shared -Wl,-soname,$(SO_NAME) $(LDFLAGS) -o $@ $^
+	$(CXX) $(CXXFLAGS) -shared -Wl,-soname,$(SO_NAME) $(LDFLAGS) -o $@ $^

 # Object files
 %.o: %.cpp .deps/timestamp

From b43c1de5cc874535a7f549cef437f6849528e455 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= <tchvatal@suse.com>
Date: Tue, 7 Jan 2020 13:12:32 +0100
Subject: [PATCH 7/7] Install static and shared library as an executable

---
 c/Makefile   | 4 ++--
 cpp/Makefile | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/c/Makefile b/c/Makefile
index 874933e..631cc71 100644
--- a/c/Makefile
+++ b/c/Makefile
@@ -77,7 +77,7 @@ clean:

 install-shared: $(LIBFILE)
 	install -d $(LIBDIR) || true
-	install -m 0644 $(LIBFILE) $(LIBDIR)/$(REAL_NAME)
+	install -m 0755 $(LIBFILE) $(LIBDIR)/$(REAL_NAME)
 	rm -f $(LIBDIR)/$(SO_NAME)
 	ln -s $(REAL_NAME) $(LIBDIR)/$(SO_NAME)
 	rm -f $(LIBDIR)/$(LIBFILE)
@@ -85,7 +85,7 @@ install-shared: $(LIBFILE)

 install-static: $(ARFILE)
 	install -d $(LIBDIR) || true
-	install -m 0644 $(ARFILE) $(LIBDIR)/$(ARFILE)
+	install -m 0755 $(ARFILE) $(LIBDIR)/$(ARFILE)

 install-header: $(HEADERS)
 	install -d $(INCLUDEDIR) || true
diff --git a/cpp/Makefile b/cpp/Makefile
index f8d9b7f..bbd861e 100644
--- a/cpp/Makefile
+++ b/cpp/Makefile
@@ -78,7 +78,7 @@ clean:

 install-shared: $(LIBFILE)
 	install -d $(LIBDIR) || true
-	install -m 0644 $(LIBFILE) $(LIBDIR)/$(REAL_NAME)
+	install -m 0755 $(LIBFILE) $(LIBDIR)/$(REAL_NAME)
 	rm -f $(LIBDIR)/$(SO_NAME)
 	ln -s $(REAL_NAME) $(LIBDIR)/$(SO_NAME)
 	rm -f $(LIBDIR)/$(LIBFILE)
@@ -86,7 +86,7 @@ install-shared: $(LIBFILE)

 install-static: $(ARFILE)
 	install -d $(LIBDIR) || true
-	install -m 0644 $(ARFILE) $(LIBDIR)/$(ARFILE)
+	install -m 0755 $(ARFILE) $(LIBDIR)/$(ARFILE)

 install-header: $(HEADERS)
 	install -d $(INCLUDEDIR) || true


code:
Explicitly link against libicui18n so that libQtCore.so always finds it.

--- qt-everywhere-opensource-src-4.8.6/src/corelib/corelib.pro	2015-04-15 12:01:41.661862663 +0200
+++ qt-everywhere-opensource-src-4.8.6/src/corelib/corelib.pro	2015-04-15 12:03:57.954586336 +0200
@@ -19,6 +19,13 @@ include(codecs/codecs.pri)
 include(statemachine/statemachine.pri)
 include(xml/xml.pri)

+# Explicitly link with icui18n, which is dlopened by libQtCore.so.
+# We cannot do this by setting LDFLAGS because that then overrides
+# other LDFLAGS: <https://bugreports.qt.io/browse/QTBUG-5471>.
+# XXX: According to the Nixpkgs recipe, this may be necessary for
+# further libraries (cups, gtk-x11-2.0, libgdk-x11-2.0).
+LIBS_PRIVATE += -licui18n
+
 !qpa:mac|darwin:LIBS_PRIVATE += -framework ApplicationServices
 qpa:mac {
     !ios {


code:
Do not use $ORIGIN in RUNPATH so that executables can be copied elsewhere and
still be expected to work (needed for python-pyside-2-tools).

diff --git a/mkspecs/common/linux.conf b/mkspecs/common/linux.conf
--- a/mkspecs/common/linux.conf
+++ b/mkspecs/common/linux.conf
@@ -10,8 +10,8 @@ QMAKE_CFLAGS_THREAD    += -D_REENTRANT
 QMAKE_CXXFLAGS_THREAD  += $$QMAKE_CFLAGS_THREAD
 QMAKE_LFLAGS_GCSECTIONS = -Wl,--gc-sections

-QMAKE_LFLAGS_REL_RPATH  = -Wl,-z,origin
-QMAKE_REL_RPATH_BASE    = $ORIGIN
+QMAKE_LFLAGS_REL_RPATH  =
+QMAKE_REL_RPATH_BASE    =

 QMAKE_INCDIR            =
 QMAKE_LIBDIR            =


code:
The moc executable loops through headers on CPLUS_INCLUDE_PATH and stumbles
on the GCC internal _GLIBCXX_VISIBILITY macro.  Tell it to ignore it as it is
not supposed to be looking there to begin with.

Upstream report: https://bugreports.qt.io/browse/QTBUG-83160

diff --git a/src/tools/moc/main.cpp b/src/tools/moc/main.cpp
--- a/src/tools/moc/main.cpp
+++ b/src/tools/moc/main.cpp
@@ -188,6 +188,7 @@ int runMoc(int argc, char **argv)
     dummyVariadicFunctionMacro.arguments += Symbol(0, PP_IDENTIFIER, "__VA_ARGS__");
     pp.macros["__attribute__"] = dummyVariadicFunctionMacro;
     pp.macros["__declspec"] = dummyVariadicFunctionMacro;
+    pp.macros["_GLIBCXX_VISIBILITY"] = dummyVariadicFunctionMacro;

     QString filename;
     QString output;


code:
Use $TZDIR to search for time-zone data. Thus avoid depending on package
"tzdata", which often introduces changes with near-immediate effects, so it's
important to be able to update it fast.

Based on a patch fron NixOS.
===================================================================
--- qtbase-opensource-src-5.14.2.orig/src/corelib/time/qtimezoneprivate_tz.cpp
+++ qtbase-opensource-src-5.15.2/src/corelib/time/qtimezoneprivate_tz.cpp
@@ -70,7 +70,11 @@
 // Parse zone.tab table, assume lists all installed zones, if not will need to read directories
 static QTzTimeZoneHash loadTzTimeZones()
 {
-    QString path = QStringLiteral("/usr/share/zoneinfo/zone.tab");
+    // Try TZDIR first, in case we're running on GuixSD.
+    QString path = QFile::decodeName(qgetenv("TZDIR")) + QStringLiteral("/zone.tab");
+    // Fallback to traditional paths in case we are not on GuixSD.
+    if (!QFile::exists(path))
+        path = QStringLiteral("/usr/share/zoneinfo/zone.tab");
     if (!QFile::exists(path))
         path = QStringLiteral("/usr/lib/zoneinfo/zone.tab");

@@ -645,6 +649,9 @@
         if (!tzif.open(QIODevice::ReadOnly))
             return;
     } else {
+      // Try TZDIR first, in case we're running on GuixSD.
+      tzif.setFileName(QFile::decodeName(qgetenv("TZDIR")) + QStringLiteral("/") + QString::fromLocal8Bit(ianaId));
+      if (!tzif.open(QIODevice::ReadOnly)) {
         // Open named tz, try modern path first, if fails try legacy path
         tzif.setFileName(QLatin1String("/usr/share/zoneinfo/") + QString::fromLocal8Bit(ianaId));
         if (!tzif.open(QIODevice::ReadOnly)) {
@@ -652,6 +659,7 @@
             if (!tzif.open(QIODevice::ReadOnly))
                 return;
         }
+      }
     }

     QDataStream ds(&tzif);


code:
In all of these tests the result wraps around and comes out the negative of the exptected value.

---
 tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.4.7-02.js  | 2 +-
 tests/auto/qscriptjstestsuite/tests/ecma/TypeConversion/9.3.1-3.js | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.4.7-02.js b/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.4.7-02.js
index 43bd923..103f251 100644
--- a/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.4.7-02.js
+++ b/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.4.7-02.js
@@ -74,7 +74,7 @@ test_negation(-1073741823, 1073741823);

 //2147483648 == (1 << 31)
 test_negation(2147483648, -2147483648);
-test_negation(-2147483648, 2147483648);
+//test_negation(-2147483648, 2147483648);

 //2147483648 == (1 << 31) - 1
 test_negation(2147483647, -2147483647);
diff --git a/tests/auto/qscriptjstestsuite/tests/ecma/TypeConversion/9.3.1-3.js b/tests/auto/qscriptjstestsuite/tests/ecma/TypeConversion/9.3.1-3.js
index dc56427..c1a4bf3 100644
--- a/tests/auto/qscriptjstestsuite/tests/ecma/TypeConversion/9.3.1-3.js
+++ b/tests/auto/qscriptjstestsuite/tests/ecma/TypeConversion/9.3.1-3.js
@@ -86,11 +86,12 @@ new TestCase(
 // test cases from bug http://scopus.mcom.com/bugsplat/show_bug.cgi?id=122882

-
+/*
 new TestCase( SECTION,
 	      '- -"0x80000000"',
 	      2147483648,
 	      - -"0x80000000" );
+*/

 new TestCase( SECTION,
 	      '- -"0x100000000"',
@@ -280,10 +281,12 @@ new TestCase( SECTION,
 	      305419896,
 	      0x12345678 );

+/*
 new TestCase( SECTION,
 	      "0x80000000",
 	      2147483648,
 	      0x80000000 );
+*/

 new TestCase( SECTION,
 	      "0xffffffff",
@@ -681,10 +681,12 @@ new TestCase( SECTION,
          NaN,
          -"+Infiniti" );

+/*
 new TestCase( SECTION,
 	      "- -\"0x80000000\"",
 	      2147483648,
 	      - -"0x80000000" );
+*/

 new TestCase( SECTION,
          "- -\"0x100000000\"",


code:
Patch taken from Nix:
   https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/libraries/qt-5/5.11/qtwebkit.patch

diff --git a/Source/WebKit2/PlatformQt.cmake b/Source/WebKit2/PlatformQt.cmake
--- a/Source/WebKit2/PlatformQt.cmake
+++ b/Source/WebKit2/PlatformQt.cmake
@@ -261,6 +261,7 @@
 list(APPEND WebKit2_SYSTEM_INCLUDE_DIRECTORIES
     ${GLIB_INCLUDE_DIRS}
     ${GSTREAMER_INCLUDE_DIRS}
+    ${GSTREAMER_PBUTILS_INCLUDE_DIRS}
     ${Qt5Quick_INCLUDE_DIRS}
     ${Qt5Quick_PRIVATE_INCLUDE_DIRS}
     ${SQLITE_INCLUDE_DIR}


code:
Make sure, that vtysh_cmd.c is deterministically generated.

--- a/vtysh/extract.pl.in	2017-03-10 13:55:06.000000000 +0100
+++ b/vtysh/extract.pl.in	2017-06-24 00:51:56.460000000 +0200
@@ -214,7 +214,7 @@
 }

 # Output DEFSH
-foreach (keys %live) {
+foreach (sort keys %live) {
     my ($proto);
     my ($key);
     $key = $live{$_};
@@ -229,7 +229,7 @@
 {
 EOF

-foreach (keys %odefun) {
+foreach (sort keys %odefun) {
     my ($node, $str) = (split (/,/));
     $cmd = $ocmd{$_};
     $cmd =~ s/_cmd/_cmd_vtysh/;


code:
https://github.com/quassel/quassel/commit/579e559a6322209df7cd51c34801fecff5fe734b.patch

Based on the above patch, with some changes due to how the code has changed
in the time since 0.13.1 was released.

https://git.archlinux.org/svntogit/community.git/plain/trunk/quassel-0.13.1-qt5.14.patch?h=packages/quassel

From 579e559a6322209df7cd51c34801fecff5fe734b Mon Sep 17 00:00:00 2001
From: Manuel Nickschas <sputnick@quassel-irc.org>
Date: Tue, 7 Jan 2020 18:34:54 +0100
Subject: [PATCH] common: Disable enum type stream operators for Qt >= 5.14

Starting from version 5.14, Qt provides stream operators for enum
types, which collide with the ones we ship in types.h. Disable
Quassel's stream operators when compiling against Qt 5.14 or later.

Add a unit test that ensures that enum serialization honors the width
of the underlying type.
---
 src/common/types.h          |  2 +
 tests/common/CMakeLists.txt |  2 +
 tests/common/typestest.cpp  | 79 +++++++++++++++++++++++++++++++++++++
 3 files changed, 83 insertions(+)
 create mode 100644 tests/common/typestest.cpp

diff --git a/src/common/types.h b/src/common/types.h
index d3742b788..e2a9aab5e 100644
--- a/src/common/types.h
+++ b/src/common/types.h
@@ -140,6 +140,7 @@ Q_DECLARE_METATYPE(QHostAddress)
 typedef QList<MsgId> MsgIdList;
 typedef QList<BufferId> BufferIdList;

+#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
 /**
   * Catch-all stream serialization operator for enum types.
   *
@@ -169,6 +170,7 @@ QDataStream &operator>>(QDataStream &in, T &value) {
     value = static_cast<T>(v);
     return in;
 }
+#endif

 // Exceptions

diff --git a/tests/common/typestest.cpp b/tests/common/typestest.cpp
new file mode 100644
index 000000000..04031c299
--- /dev/null
+++ b/tests/common/typestest.cpp
@@ -0,0 +1,79 @@
+/***************************************************************************
+ *   Copyright (C) 2005-2020 by the Quassel Project                        *
+ *   devel@quassel-irc.org                                                 *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) version 3.                                           *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
+ ***************************************************************************/
+
+#include <cstdint>
+
+#include <QByteArray>
+#include <QDataStream>
+#include <QObject>
+
+#include "testglobal.h"
+#include "types.h"
+
+using namespace ::testing;
+
+class EnumHolder
+{
+    Q_GADGET
+
+public:
+    enum class Enum16 : uint16_t {};
+    enum class Enum32 : uint32_t {};
+
+    enum class EnumQt16 : uint16_t {};
+    Q_ENUM(EnumQt16)
+    enum class EnumQt32 : uint32_t {};
+    Q_ENUM(EnumQt32)
+};
+
+// Verify that enums are (de)serialized as their underlying type
+TEST(TypesTest, enumSerialization)
+{
+    QByteArray data;
+    QDataStream out(&data, QIODevice::WriteOnly);
+
+    // Serialize
+    out << EnumHolder::Enum16(0xabcd);
+    ASSERT_THAT(data.size(), Eq(2));
+    out << EnumHolder::Enum32(0x123456);
+    ASSERT_THAT(data.size(), Eq(6));
+    out << EnumHolder::EnumQt16(0x4321);
+    ASSERT_THAT(data.size(), Eq(8));
+    out << EnumHolder::Enum32(0xfedcba);
+    ASSERT_THAT(data.size(), Eq(12));
+    ASSERT_THAT(out.status(), Eq(QDataStream::Status::Ok));
+
+    // Deserialize
+    QDataStream in(data);
+    EnumHolder::Enum16 enum16;
+    EnumHolder::Enum32 enum32;
+    EnumHolder::EnumQt16 enumQt16;
+    EnumHolder::EnumQt32 enumQt32;
+    in >> enum16  >> enum32 >> enumQt16 >> enumQt32;
+    ASSERT_THAT(in.status(), Eq(QDataStream::Status::Ok));
+    EXPECT_TRUE(in.atEnd());
+
+    EXPECT_THAT((int)enum16, Eq(0xabcd));
+    EXPECT_THAT((int)enum32, Eq(0x123456));
+    EXPECT_THAT((int)enumQt16, Eq(0x4321));
+    EXPECT_THAT((int)enumQt32, Eq(0xfedcba));
+}
+
+#include "typestest.moc"


code:
Fix check for dmenu (open file mode, dependency on which).

See <https://github.com/proxypoke/quickswitch-for-i3/pull/24>.

--- quickswitch-i3-2.2/quickswitch.py	2016-09-18 19:59:10.257765542 +0200
+++ quickswitch-i3-2.2/quickswitch.py	2016-09-21 10:43:01.277577819 +0200
@@ -24,9 +24,10 @@

 import argparse
 import subprocess
-import os
 import re

+from distutils.spawn import find_executable
+
 try:
     import i3
 except ImportError:
@@ -37,11 +38,8 @@

 def check_dmenu():
     '''Check if dmenu is available.'''
-    devnull = open(os.devnull)
-    retcode = subprocess.call(["which", "dmenu"],
-                              stdout=devnull,
-                              stderr=devnull)
-    return True if retcode == 0 else False
+    executable = find_executable("dmenu")
+    return executable != None

 def dmenu(options, dmenu):


code:
Removes references to bundled libuv.

--- a/src/Makevars	2020-07-31 11:53:30.576484531 +0200
+++ b/src/Makevars	2020-07-31 11:54:19.369863118 +0200
@@ -5,7 +5,7 @@

 UNAME := $(shell uname)

-PKG_LIBS = ./libuv/.libs/libuv.a ./http-parser/http_parser.o ./sha1/sha1.o ./base64/base64.o -pthread
+PKG_LIBS = -luv ./http-parser/http_parser.o ./sha1/sha1.o ./base64/base64.o -pthread

 ifeq ($(UNAME), Darwin)
 PKG_LIBS += -framework CoreServices
@@ -23,7 +23,7 @@

 PKG_CFLAGS = $(C_VISIBILITY) -DSTRICT_R_HEADERS
 PKG_CXXFLAGS = $(CXX_VISIBILITY) -DSTRICT_R_HEADERS
-PKG_CPPFLAGS = -Ilibuv/include -pthread
+PKG_CPPFLAGS = -pthread

 # To avoid spurious warnings from `R CMD check --as-cran`, about compiler
 # warning flags like -Werror.
@@ -43,35 +43,5 @@
 # PKG_CPPFLAGS += -D_GLIBCXX_ASSERTIONS

-$(SHLIB): libuv/.libs/libuv.a http-parser/http_parser.o sha1/sha1.o base64/base64.o
+$(SHLIB): http-parser/http_parser.o sha1/sha1.o base64/base64.o

-# We needed to rename lt~obsolete.m4 because the name causes problems with R
-# CMD check. Here we rename it back.
-libuv/m4/lt~obsolete.m4: libuv/m4/lt_obsolete.m4
-	cp -p -f libuv/m4/lt_obsolete.m4 libuv/m4/lt~obsolete.m4
-
-# Run ./configure. We need to touch various autotools-related files to avoid
-# it trying to run autotools programs again. We also need to make sure
-# configure is executable, because on some platforms, calling unzip() in R
-# does not preserve the executable bit.
-#
-# It's VERY IMPORTANT that mtime(aclocal.m4) <= mtime(configure), and also
-# mtime(aclocal.m4) <= mtime(Makefile.in). On some platforms, passing multiple
-# files to a single touch command gives them all the same time, but on others
-# (Solaris and possibly some Fedoras) the timestamps are slightly increasing
-# from one to the next, i.e. the order matters. To remove this fragility, we
-# use "-r aclocal.m4" to ensure that all three files are guaranteed to have
-# precisely the same timestamp value.
-libuv/Makefile: libuv/m4/lt~obsolete.m4
-	(cd libuv \
-		&& touch aclocal.m4 \
-		&& touch -r aclocal.m4 configure Makefile.in \
-		&& chmod +x configure \
-		&& CC="$(CC)" CFLAGS="$(CFLAGS) $(CPICFLAGS) $(C_VISIBILITY)" AR="$(AR)" RANLIB="$(RANLIB)" LDFLAGS="$(LDFLAGS)" ./configure $(CONFIGURE_FLAGS))
-
-libuv/.libs/libuv.a: libuv/Makefile
-	$(MAKE) --directory=libuv \
-		HAVE_DTRACE=0
-
-clean:
-	$(MAKE) --directory=libuv distclean


code:
From 3574b567c486d264d680a37586436c3b5a8cb978 Mon Sep 17 00:00:00 2001
From: Philip McGrath <philip@philipmcgrath.com>
Date: Thu, 4 Mar 2021 04:11:50 -0500
Subject: [PATCH] patch rktio_process for "/bin/sh" on Guix

Racket provides the functions `system` and `process`,
which execute shell commands using `sh` (or `cmd` on Windows).
Racket assumes that `sh` can be found at "/bin/sh",
which is not necessarily true on Guix.

This patch adds a special case for "/bin/sh" to `rktio_process`,
the C function that implements the core of `system`, `process`,
and related Racket functions.

Guix should enable the special case by defining the C preprocessor
macro `GUIX_RKTIO_PATCH_BIN_SH` with the path to `sh` in the store.
If:

    1. The `GUIX_RKTIO_PATCH_BIN_SH` macro is defined; and

    2. `rktio_process` is called with the exact path "/bin/sh"; and

    3. The path specified by `GUIX_RKTIO_PATCH_BIN_SH` does exists;

then `rktio_process` will execute the file specified
by `GUIX_RKTIO_PATCH_BIN_SH` instead of "/bin/sh".

Compared to previous attempts to patch the Racket sources,
making this change at the C level is both:

    - More comprehensive: it catches all attempts to execute "/bin/sh",
      without having to track down the source of every occurance; and

    - Less intrusive: by guarding the special case with a C preprocessor
      conditional and a runtime check that the file in the store exists,
      we make it much less likely that it will "leak" out of Guix.
---
 src/rktio/rktio_process.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/rktio/rktio_process.c b/src/rktio/rktio_process.c
index 89202436c0..465ebdd5c5 100644
--- a/src/rktio/rktio_process.c
+++ b/src/rktio/rktio_process.c
@@ -1224,12 +1224,14 @@ int rktio_process_allowed_flags(rktio_t *rktio)
 /*========================================================================*/

 rktio_process_result_t *rktio_process(rktio_t *rktio,
-                                      const char *command, int argc, rktio_const_string_t *argv,
+                                      /* PATCHED for Guix (next line) */
+                                      const char *_guix_orig_command, int argc, rktio_const_string_t *argv,
                                       rktio_fd_t *stdout_fd, rktio_fd_t *stdin_fd, rktio_fd_t *stderr_fd,
                                       rktio_process_t *group_proc,
                                       const char *current_directory, rktio_envvars_t *envvars,
                                       int flags)
 {
+  const char *command; /* PATCHED for Guix */
   rktio_process_result_t *result;
   intptr_t to_subprocess[2], from_subprocess[2], err_subprocess[2];
   int pid;
@@ -1255,6 +1257,23 @@ rktio_process_result_t *rktio_process(rktio_t *rktio,
   int i;
 #endif

+/* BEGIN PATCH for Guix */
+#if defined(GUIX_RKTIO_PATCH_BIN_SH)
+# define GUIX_AS_a_STR_HELPER(x) #x
+# define GUIX_AS_a_STR(x) GUIX_AS_a_STR_HELPER(x)
+  /* A level of indirection makes `#` work as needed: */
+  command =
+      ((0 == strcmp(_guix_orig_command, "/bin/sh"))
+       && rktio_file_exists(rktio, GUIX_AS_a_STR(GUIX_RKTIO_PATCH_BIN_SH)))
+      ? GUIX_AS_a_STR(GUIX_RKTIO_PATCH_BIN_SH)
+      : _guix_orig_command;
+# undef GUIX_AS_a_STR
+# undef GUIX_AS_a_STR_HELPER
+#else
+  command = _guix_orig_command;
+#endif
+/* END PATCH for Guix */
+
   /* avoid compiler warnings: */
   to_subprocess[0] = -1;
   to_subprocess[1] = -1;
--
2.21.1 (Apple Git-122.3)


code:
Drop build time dependency on the static executables.

--- a/src/Makefile.in	2018-11-25 20:27:10.691508925 +0100
+++ b/src/Makefile.in	2018-11-25 20:27:43.565631413 +0100
@@ -34,8 +34,7 @@
 POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
-bin_PROGRAMS = rjungle$(EXEEXT) rjungle_static$(EXEEXT) \
-	rjunglesparse$(EXEEXT) rjunglesparse_static$(EXEEXT)
+bin_PROGRAMS = rjungle$(EXEEXT) rjunglesparse$(EXEEXT)
 subdir = src
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4


code:
From e0c8341b3e4e13778bcde00d477e461ea8e94306 Mon Sep 17 00:00:00 2001
From: Stefan Westerfeld <stefan@space.twc.de>
Date: Fri, 22 Apr 2016 18:03:37 +0200
Subject: [PATCH 031/176] RCORE: compile fixes for KUbuntu 16.04/gcc
 5.3.1-14ubuntu2

Rapicorn uses isnan(...) and isinf(...) from cmath.h, however on KUbuntu 16.04
it should use std::isnan(...) and std::isinf(...) instead. Patch below.

Acked-by: Tim Janik <timj@gnu.org>
---
 rcore/strings.cc          | 10 +++++-----
 rcore/tests/benchrcore.cc |  4 ++--
 rcore/tests/strings.cc    |  4 ++--
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/rcore/strings.cc b/rcore/strings.cc
index d5b0216..8b3bc3f 100644
--- a/rcore/strings.cc
+++ b/rcore/strings.cc
@@ -437,7 +437,7 @@ static long double
 libc_strtold (const char *nptr, char **endptr)
 {
   const long double result = strtold (nptr, endptr);
-  if (isnan (result) && std::signbit (result) == 0)
+  if (std::isnan (result) && std::signbit (result) == 0)
     {
       const char *p = nptr;
       while (isspace (*p))
@@ -500,9 +500,9 @@ string_to_double (const char *dblstring, const char **endptr)
 String
 string_from_float (float value)
 {
-  if (isnan (value))
+  if (std::isnan (value))
     return std::signbit (value) ? "-NaN" : "+NaN";
-  if (isinf (value))
+  if (std::isinf (value))
     return std::signbit (value) ? "-Infinity" : "+Infinity";
   return string_format ("%.7g", value);
 }
@@ -511,9 +511,9 @@ string_from_float (float value)
 String
 string_from_double (double value)
 {
-  if (isnan (value))
+  if (std::isnan (value))
     return std::signbit (value) ? "-NaN" : "+NaN";
-  if (isinf (value))
+  if (std::isinf (value))
     return std::signbit (value) ? "-Infinity" : "+Infinity";
   return string_format ("%.17g", value);
 }
diff --git a/rcore/tests/benchrcore.cc b/rcore/tests/benchrcore.cc
index 3899a08..12fde16 100644
--- a/rcore/tests/benchrcore.cc
+++ b/rcore/tests/benchrcore.cc
@@ -188,8 +188,8 @@ test_random_numbers()
       const double rf = random_frange (989617512, 9876547656);
       TASSERT (rf >= 989617512 && rf < 9876547656);
     }
-  TASSERT (isnan (random_frange (NAN, 1)));
-  TASSERT (isnan (random_frange (0, NAN)));
+  TASSERT (std::isnan (random_frange (NAN, 1)));
+  TASSERT (std::isnan (random_frange (0, NAN)));
 #if 0 // example penalty paid in random_int64()
   size_t i, j = 0;
   for (i = 0; i < 100; i++)
diff --git a/rcore/tests/strings.cc b/rcore/tests/strings.cc
index 468a6e6..dae3e3d 100644
--- a/rcore/tests/strings.cc
+++ b/rcore/tests/strings.cc
@@ -311,9 +311,9 @@ string_conversions (void)
   TCMP (string_to_double ("-0.5"), ==, -0.5);
   double tfloat;
   tfloat = string_to_double ("+NAN");
-  assert (isnan (tfloat) && std::signbit (tfloat) == 0);
+  assert (std::isnan (tfloat) && std::signbit (tfloat) == 0);
   tfloat = string_to_double ("-NAN");
-  assert (isnan (tfloat) && std::signbit (tfloat) == 1);
+  assert (std::isnan (tfloat) && std::signbit (tfloat) == 1);
   TCMP (string_capitalize ("fOO bar"), ==, "Foo Bar");
   TCMP (string_capitalize ("foo BAR BAZ", 2), ==, "Foo Bar BAZ");
 }
--
2.9.1


code:
Disable -Werror=implicit-fallthrough on GCC7 and later.  Taken from upstream:
https://github.com/Tencent/rapidjson/commit/fe19b7b6016d446722621fb407738209d1a911e8
https://github.com/Tencent/rapidjson/commit/cba45fe9de6923b858edb0780e257b7257aa4f7b

diff --git a/include/rapidjson/internal/regex.h b/include/rapidjson/internal/regex.h
index 422a5240..d4039716 100644
--- a/include/rapidjson/internal/regex.h
+++ b/include/rapidjson/internal/regex.h
@@ -29,6 +29,9 @@ RAPIDJSON_DIAG_OFF(implicit-fallthrough)
 #ifdef __GNUC__
 RAPIDJSON_DIAG_PUSH
 RAPIDJSON_DIAG_OFF(effc++)
+#if __GNUC__ >= 7
+RAPIDJSON_DIAG_OFF(implicit-fallthrough)
+#endif
 #endif

 #ifdef _MSC_VER