]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 59077-59104 via svnmerge from
authorGuido van Rossum <guido@python.org>
Thu, 22 Nov 2007 00:30:02 +0000 (00:30 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 22 Nov 2007 00:30:02 +0000 (00:30 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r59078 | brett.cannon | 2007-11-20 16:16:20 -0800 (Tue, 20 Nov 2007) | 2 lines

  Remove a unneeded line that had typos.
........
  r59081 | christian.heimes | 2007-11-20 16:46:21 -0800 (Tue, 20 Nov 2007) | 1 line

  Fixed #1372: zlibmodule.c: int overflow in PyZlib_decompress
........
  r59082 | brett.cannon | 2007-11-20 16:47:36 -0800 (Tue, 20 Nov 2007) | 6 lines

  doctest assumed that a package's __loader__.get_data() method used universal
  newlines; it doesn't.  To rectify this the string returned replaces all
  instances of os.linesep with '\n' to fake universal newline support.

  Backport candidate.
........
  r59084 | brett.cannon | 2007-11-20 16:58:03 -0800 (Tue, 20 Nov 2007) | 2 lines

  Add a missing check before deleting a package's __loader__.
........
  r59088 | christian.heimes | 2007-11-20 17:17:28 -0800 (Tue, 20 Nov 2007) | 2 lines

  Added NEWS entry
  Thanks for the reminder, Brett
........
  r59089 | amaury.forgeotdarc | 2007-11-20 17:38:26 -0800 (Tue, 20 Nov 2007) | 2 lines

  Add a NEWS entry for r59076.
........
  r59091 | christian.heimes | 2007-11-20 18:50:06 -0800 (Tue, 20 Nov 2007) | 2 lines

  Final fix for #1403
  The Windows installer and some Linux distros are using compileall to compile all py files in the Lib/ directory. However no test exists to check if all py files can be compiled. I figured out that make testall is the easiest way to test compileall.
........

Lib/doctest.py
Lib/test/test_doctest.py
Modules/zlibmodule.c

index 97bc05358f31c5db976a9d79c5bdfee3d8a85bb0..eee2f519dbc8176cc7603c1d467ada4801b75ce0 100644 (file)
@@ -209,8 +209,11 @@ def _load_testfile(filename, package, module_relative, encoding):
         filename = _module_relative_path(package, filename)
         if hasattr(package, '__loader__'):
             if hasattr(package.__loader__, 'get_data'):
-                return (package.__loader__.get_data(filename).decode(encoding),
-                        filename)
+                file_contents = package.__loader__.get_data(filename)
+                file_contents = file_contents.decode(encoding)
+                # get_data() opens files as 'rb', so one must do the equivalent
+                # conversion as universal newlines would do.
+                return file_contents.replace(os.linesep, '\n'), filename
     return open(filename, encoding=encoding).read(), filename
 
 def _indent(s, indent=4):
index be2ffe26122f002527deae31440b02cd18c51516..3b89097312991d0f9177e4749a47367cc633d55c 100644 (file)
@@ -1912,6 +1912,24 @@ def test_DocFileSuite():
          >>> suite.run(unittest.TestResult())
          <unittest.TestResult run=3 errors=0 failures=2>
 
+       Support for using a package's __loader__.get_data() is also
+       provided.
+
+         >>> import unittest, pkgutil, test
+         >>> if not hasattr(test, '__loader__'):
+         ...     test.__loader__ = pkgutil.get_loader(test)
+         ...     added_loader = True
+         >>> try:
+         ...     suite = doctest.DocFileSuite('test_doctest.txt',
+         ...                                  'test_doctest2.txt',
+         ...                                  'test_doctest4.txt',
+         ...                                  package='test')
+         ...     suite.run(unittest.TestResult())
+         ... finally:
+         ...     if added_loader:
+         ...         del test.__loader__
+         <unittest.TestResult run=3 errors=0 failures=2>
+
        '/' should be used as a path separator.  It will be converted
        to a native separator at run time:
 
@@ -1973,8 +1991,6 @@ def test_DocFileSuite():
 
        And, you can provide setUp and tearDown functions:
 
-       You can supply setUp and teatDoen functions:
-
          >>> def setUp(t):
          ...     import test.test_doctest
          ...     test.test_doctest.sillySetup = True
index fd6c0b790c92995b9bbaaebef6f29ac69d0aae6b..8f3202d7737fc7a683a52dbf1c894ef5679aea00 100644 (file)
@@ -197,10 +197,11 @@ PyZlib_decompress(PyObject *self, PyObject *args)
     PyObject *result_str;
     Byte *input;
     int length, err;
-    int wsize=DEF_WBITS, r_strlen=DEFAULTALLOC;
+    int wsize=DEF_WBITS;
+    Py_ssize_t r_strlen=DEFAULTALLOC;
     z_stream zst;
 
-    if (!PyArg_ParseTuple(args, "s#|ii:decompress",
+    if (!PyArg_ParseTuple(args, "s#|in:decompress",
                          &input, &length, &wsize, &r_strlen))
        return NULL;