[Python-checkins] cpython (merge 3.4 -> 3.4): Merge heads

serhiy.storchaka python-checkins at python.org
Sun Feb 15 13:39:23 CET 2015


https://hg.python.org/cpython/rev/7072bbe16a06
changeset:   94628:7072bbe16a06
branch:      3.4
parent:      94627:8bb36e8a952e
parent:      94622:ad4a8176a71a
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Sun Feb 15 14:02:15 2015 +0200
summary:
  Merge heads

files:
  Doc/library/binascii.rst     |   6 ------
  Lib/http/server.py           |   5 ++++-
  Lib/test/test_gdb.py         |   2 ++
  Lib/test/test_httpservers.py |  14 ++++++++++++++
  Lib/test/test_zipfile.py     |   8 ++++++++
  Modules/binascii.c           |   4 ++--
  Python/frozenmain.c          |  15 +++++++++------
  7 files changed, 39 insertions(+), 15 deletions(-)


diff --git a/Doc/library/binascii.rst b/Doc/library/binascii.rst
--- a/Doc/library/binascii.rst
+++ b/Doc/library/binascii.rst
@@ -65,9 +65,6 @@
    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 @@
    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
 
diff --git a/Lib/http/server.py b/Lib/http/server.py
--- a/Lib/http/server.py
+++ b/Lib/http/server.py
@@ -82,7 +82,10 @@
 
 __version__ = "0.6"
 
-__all__ = ["HTTPServer", "BaseHTTPRequestHandler"]
+__all__ = [
+    "HTTPServer", "BaseHTTPRequestHandler",
+    "SimpleHTTPRequestHandler", "CGIHTTPRequestHandler",
+]
 
 import html
 import http.client
diff --git a/Lib/test/test_gdb.py b/Lib/test/test_gdb.py
--- a/Lib/test/test_gdb.py
+++ b/Lib/test/test_gdb.py
@@ -190,6 +190,8 @@
             '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.',
diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py
--- a/Lib/test/test_httpservers.py
+++ b/Lib/test/test_httpservers.py
@@ -760,6 +760,19 @@
         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 @@
             SimpleHTTPServerTestCase,
             CGIHTTPServerTestCase,
             SimpleHTTPRequestHandlerTestCase,
+            MiscTestCase,
         )
     finally:
         os.chdir(cwd)
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py
--- a/Lib/test/test_zipfile.py
+++ b/Lib/test/test_zipfile.py
@@ -648,7 +648,12 @@
         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 @@
     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 @@
     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 @@
     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
diff --git a/Modules/binascii.c b/Modules/binascii.c
--- a/Modules/binascii.c
+++ b/Modules/binascii.c
@@ -228,13 +228,13 @@
     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;
     }
diff --git a/Python/frozenmain.c b/Python/frozenmain.c
--- a/Python/frozenmain.c
+++ b/Python/frozenmain.c
@@ -24,11 +24,13 @@
     /* 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 @@
 #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();

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list