From 366c570d1f48df0f06707e34472b626bc97f03e3 Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Fri, 13 Feb 2015 20:48:15 +0200 Subject: [PATCH 1/6] Issue #23418: Add missing entries to http.server.__all__. Patch by Martin Panter. --- Lib/http/server.py | 5 ++++- Lib/test/test_httpservers.py | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Lib/http/server.py b/Lib/http/server.py index cfa29f44d35..a27890e6d9c 100644 --- a/Lib/http/server.py +++ b/Lib/http/server.py @@ -82,7 +82,10 @@ XXX To do: __version__ = "0.6" -__all__ = ["HTTPServer", "BaseHTTPRequestHandler"] +__all__ = [ + "HTTPServer", "BaseHTTPRequestHandler", + "SimpleHTTPRequestHandler", "CGIHTTPRequestHandler", +] import html import http.client diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py index 569341d83b4..67a4654054e 100644 --- a/Lib/test/test_httpservers.py +++ b/Lib/test/test_httpservers.py @@ -760,6 +760,19 @@ class SimpleHTTPRequestHandlerTestCase(unittest.TestCase): self.assertEqual(path, self.translated) +class MiscTestCase(unittest.TestCase): + def test_all(self): + expected = [] + blacklist = {'executable', 'nobody_uid', 'test'} + for name in dir(server): + if name.startswith('_') or name in blacklist: + continue + module_object = getattr(server, name) + if getattr(module_object, '__module__', None) == 'http.server': + expected.append(name) + self.assertCountEqual(server.__all__, expected) + + def test_main(verbose=None): cwd = os.getcwd() try: @@ -769,6 +782,7 @@ def test_main(verbose=None): SimpleHTTPServerTestCase, CGIHTTPServerTestCase, SimpleHTTPRequestHandlerTestCase, + MiscTestCase, ) finally: os.chdir(cwd) From 2476b98acfe303ecc3ed9b38107f75e05dab95c5 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sat, 14 Feb 2015 15:16:32 -0500 Subject: [PATCH 2/6] avoid reading unallocated memory when argc == 0 (closes #22633) --- Python/frozenmain.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Python/frozenmain.c b/Python/frozenmain.c index 55d05fc26f0..b05c94a7e17 100644 --- a/Python/frozenmain.c +++ b/Python/frozenmain.c @@ -24,11 +24,13 @@ Py_FrozenMain(int argc, char **argv) /* We need a second copies, as Python might modify the first one. */ wchar_t **argv_copy2 = NULL; - argv_copy = PyMem_RawMalloc(sizeof(wchar_t*) * argc); - argv_copy2 = PyMem_RawMalloc(sizeof(wchar_t*) * argc); - if (!argv_copy || !argv_copy2) { - fprintf(stderr, "out of memory\n"); - goto error; + if (argc > 0) { + argv_copy = PyMem_RawMalloc(sizeof(wchar_t*) * argc); + argv_copy2 = PyMem_RawMalloc(sizeof(wchar_t*) * argc); + if (!argv_copy || !argv_copy2) { + fprintf(stderr, "out of memory\n"); + goto error; + } } Py_FrozenFlag = 1; /* Suppress errors from getpath.c */ @@ -68,7 +70,8 @@ Py_FrozenMain(int argc, char **argv) #ifdef MS_WINDOWS PyInitFrozenExtensions(); #endif /* MS_WINDOWS */ - Py_SetProgramName(argv_copy[0]); + if (argc >= 1) + Py_SetProgramName(argv_copy[0]); Py_Initialize(); #ifdef MS_WINDOWS PyWinFreeze_ExeInit(); From 6b688d8162bc0629286644ba901dcd40c2d35303 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sat, 14 Feb 2015 22:44:35 +0200 Subject: [PATCH 3/6] Issue #22844: Fized test_gdb failure on Debian Wheezy for Z. Patch by David Edelsohn. --- Lib/test/test_gdb.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lib/test/test_gdb.py b/Lib/test/test_gdb.py index aaa5c69d49c..c57875c3dd5 100644 --- a/Lib/test/test_gdb.py +++ b/Lib/test/test_gdb.py @@ -190,6 +190,8 @@ class DebuggerTests(unittest.TestCase): 'linux-vdso.so', 'warning: Could not load shared library symbols for ' 'linux-gate.so', + 'warning: Could not load shared library symbols for ' + 'linux-vdso64.so', 'Do you need "set solib-search-path" or ' '"set sysroot"?', 'warning: Source file is more recent than executable.', From db724fe994b180d989fd07968aab44260fa5dea5 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sat, 14 Feb 2015 23:04:35 +0200 Subject: [PATCH 4/6] Issue #17753: Skip test_zipfile tests which require write access to test and email.test. --- Lib/test/test_zipfile.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py index 76e32fbfbd8..4633fe67a59 100644 --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -648,7 +648,12 @@ class PyZipFileTests(unittest.TestCase): if name + 'o' not in namelist: self.assertIn(name + 'c', namelist) + def requiresWriteAccess(self, path): + if not os.access(path, os.W_OK, effective_ids=True): + self.skipTest('requires write access to the installed location') + def test_write_pyfile(self): + self.requiresWriteAccess(os.path.dirname(__file__)) with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp: fn = __file__ if fn.endswith('.pyc') or fn.endswith('.pyo'): @@ -680,6 +685,7 @@ class PyZipFileTests(unittest.TestCase): def test_write_python_package(self): import email packagedir = os.path.dirname(email.__file__) + self.requiresWriteAccess(packagedir) with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp: zipfp.writepy(packagedir) @@ -693,6 +699,7 @@ class PyZipFileTests(unittest.TestCase): def test_write_filtered_python_package(self): import test packagedir = os.path.dirname(test.__file__) + self.requiresWriteAccess(packagedir) with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp: @@ -721,6 +728,7 @@ class PyZipFileTests(unittest.TestCase): def test_write_with_optimization(self): import email packagedir = os.path.dirname(email.__file__) + self.requiresWriteAccess(packagedir) # use .pyc if running test in optimization mode, # use .pyo if running test in debug mode optlevel = 1 if __debug__ else 0 From 50ef8a8e6707f8658c4eeab34cd68822aa80c4d2 Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Sun, 15 Feb 2015 00:05:42 +0200 Subject: [PATCH 5/6] Issue #13637: Remove outdated versionchanged directives. Patch by Martin Panter. --- Doc/library/binascii.rst | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Doc/library/binascii.rst b/Doc/library/binascii.rst index c92a8e160a9..3f7df74de98 100644 --- a/Doc/library/binascii.rst +++ b/Doc/library/binascii.rst @@ -65,9 +65,6 @@ The :mod:`binascii` module defines the following functions: data. More than one line may be passed at a time. If the optional argument *header* is present and true, underscores will be decoded as spaces. - .. versionchanged:: 3.2 - Accept only bytestring or bytearray objects as input. - .. function:: b2a_qp(data, quotetabs=False, istext=True, header=False) @@ -156,9 +153,6 @@ The :mod:`binascii` module defines the following functions: of hexadecimal digits (which can be upper or lower case), otherwise a :exc:`TypeError` is raised. - .. versionchanged:: 3.2 - Accept only bytestring or bytearray objects as input. - .. exception:: Error From 3cd30c2ceeaeabe0486a2467fd11cdc008bf6f67 Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Sun, 15 Feb 2015 00:31:00 +0200 Subject: [PATCH 6/6] Issue #13637: Improve exception message of a2b_* functions. Patch by Vajrasky Kok. --- Modules/binascii.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/binascii.c b/Modules/binascii.c index 86b63bb4f54..4e6953b8baa 100644 --- a/Modules/binascii.c +++ b/Modules/binascii.c @@ -228,13 +228,13 @@ ascii_buffer_converter(PyObject *arg, Py_buffer *buf) if (PyObject_GetBuffer(arg, buf, PyBUF_SIMPLE) != 0) { PyErr_Format(PyExc_TypeError, "argument should be bytes, buffer or ASCII string, " - "not %R", Py_TYPE(arg)); + "not '%.100s'", Py_TYPE(arg)->tp_name); return 0; } if (!PyBuffer_IsContiguous(buf, 'C')) { PyErr_Format(PyExc_TypeError, "argument should be a contiguous buffer, " - "not %R", Py_TYPE(arg)); + "not '%.100s'", Py_TYPE(arg)->tp_name); PyBuffer_Release(buf); return 0; }