Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cd4d452

Browse files
committed
Merged revisions 59077-59104 via svnmerge from
svn+ssh://[email protected]/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. ........
1 parent d05eb00 commit cd4d452

3 files changed

Lines changed: 26 additions & 6 deletions

File tree

Lib/doctest.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,11 @@ def _load_testfile(filename, package, module_relative, encoding):
209209
filename = _module_relative_path(package, filename)
210210
if hasattr(package, '__loader__'):
211211
if hasattr(package.__loader__, 'get_data'):
212-
return (package.__loader__.get_data(filename).decode(encoding),
213-
filename)
212+
file_contents = package.__loader__.get_data(filename)
213+
file_contents = file_contents.decode(encoding)
214+
# get_data() opens files as 'rb', so one must do the equivalent
215+
# conversion as universal newlines would do.
216+
return file_contents.replace(os.linesep, '\n'), filename
214217
return open(filename, encoding=encoding).read(), filename
215218

216219
def _indent(s, indent=4):

Lib/test/test_doctest.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1912,6 +1912,24 @@ def test_DocFileSuite():
19121912
>>> suite.run(unittest.TestResult())
19131913
<unittest.TestResult run=3 errors=0 failures=2>
19141914
1915+
Support for using a package's __loader__.get_data() is also
1916+
provided.
1917+
1918+
>>> import unittest, pkgutil, test
1919+
>>> if not hasattr(test, '__loader__'):
1920+
... test.__loader__ = pkgutil.get_loader(test)
1921+
... added_loader = True
1922+
>>> try:
1923+
... suite = doctest.DocFileSuite('test_doctest.txt',
1924+
... 'test_doctest2.txt',
1925+
... 'test_doctest4.txt',
1926+
... package='test')
1927+
... suite.run(unittest.TestResult())
1928+
... finally:
1929+
... if added_loader:
1930+
... del test.__loader__
1931+
<unittest.TestResult run=3 errors=0 failures=2>
1932+
19151933
'/' should be used as a path separator. It will be converted
19161934
to a native separator at run time:
19171935
@@ -1973,8 +1991,6 @@ def test_DocFileSuite():
19731991
19741992
And, you can provide setUp and tearDown functions:
19751993
1976-
You can supply setUp and teatDoen functions:
1977-
19781994
>>> def setUp(t):
19791995
... import test.test_doctest
19801996
... test.test_doctest.sillySetup = True

Modules/zlibmodule.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,11 @@ PyZlib_decompress(PyObject *self, PyObject *args)
197197
PyObject *result_str;
198198
Byte *input;
199199
int length, err;
200-
int wsize=DEF_WBITS, r_strlen=DEFAULTALLOC;
200+
int wsize=DEF_WBITS;
201+
Py_ssize_t r_strlen=DEFAULTALLOC;
201202
z_stream zst;
202203

203-
if (!PyArg_ParseTuple(args, "s#|ii:decompress",
204+
if (!PyArg_ParseTuple(args, "s#|in:decompress",
204205
&input, &length, &wsize, &r_strlen))
205206
return NULL;
206207

0 commit comments

Comments
 (0)