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

Skip to content

Commit c76a250

Browse files
committed
Merged revisions 56782-56847 via svnmerge from
svn+ssh://[email protected]/python/branches/p3yk ................ r56808 | kurt.kaiser | 2007-08-07 14:15:45 -0700 (Tue, 07 Aug 2007) | 2 lines Replace sys.exitfunc call with atexit call ................ r56835 | thomas.wouters | 2007-08-08 09:20:30 -0700 (Wed, 08 Aug 2007) | 8 lines Tests for dict comprehensions I forgot to 'svn add' when committing the actual feature. I was _sure_ I had checked in these new tests already, but I guess the checkin failed and I didn't notice. ................ r56847 | guido.van.rossum | 2007-08-09 07:03:34 -0700 (Thu, 09 Aug 2007) | 30 lines Merged revisions 56760-56846 via svnmerge from svn+ssh://[email protected]/python/trunk ........ r56762 | georg.brandl | 2007-08-06 00:37:58 -0700 (Mon, 06 Aug 2007) | 2 lines Place #ifdef Py_USING_UNICODE around decode_unicode(). ........ r56763 | georg.brandl | 2007-08-06 00:39:09 -0700 (Mon, 06 Aug 2007) | 2 lines Replace unnecessary function call. ........ r56764 | georg.brandl | 2007-08-06 00:52:20 -0700 (Mon, 06 Aug 2007) | 2 lines Patch #1765839: add link to https+proxy urllib2 opener. ........ r56797 | georg.brandl | 2007-08-07 00:13:24 -0700 (Tue, 07 Aug 2007) | 2 lines Bug #1769002: fix a now-wrong sentence in the tutorial. ........ r56830 | georg.brandl | 2007-08-08 06:03:41 -0700 (Wed, 08 Aug 2007) | 3 lines Revert the fix for #1548891, it broke backwards compatibility with arbitrary read buffers. Fixes #1730114. ........ r56833 | georg.brandl | 2007-08-08 06:50:02 -0700 (Wed, 08 Aug 2007) | 2 lines Fix compilation warning. ........ ................
1 parent 34d1928 commit c76a250

8 files changed

Lines changed: 83 additions & 14 deletions

File tree

Doc/howto/urllib2.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,9 @@ steps to setting up a `Basic Authentication`_ handler : ::
541541
.. note::
542542

543543
Currently ``urllib2`` *does not* support fetching of ``https``
544-
locations through a proxy. This can be a problem.
544+
locations through a proxy. However, this can be enabled by extending
545+
urllib2 as shown in the recipe [#]_.
546+
545547

546548
Sockets and Layers
547549
==================
@@ -596,3 +598,6 @@ This document was reviewed and revised by John Lee.
596598
is set to use the proxy, which urllib2 picks up on. In order to test
597599
scripts with a localhost server, I have to prevent urllib2 from using
598600
the proxy.
601+
.. [#] urllib2 opener for SSL proxy (CONNECT method): `ASPN Cookbook Recipe
602+
<http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/456195>`_.
603+

Doc/lib/libstringio.tex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ \section{\module{cStringIO} ---
7878
module, those provided by this module are not able to accept Unicode
7979
strings that cannot be encoded as plain \ASCII{} strings.
8080

81+
Calling \function{StringIO()} with a Unicode string parameter populates
82+
the object with the buffer representation of the Unicode string, instead of
83+
encoding the string.
84+
8185
Another difference from the \refmodule{StringIO} module is that calling
8286
\function{StringIO()} with a string parameter creates a read-only object.
8387
Unlike an object created without a string parameter, it does not have

Doc/tut/tut.tex

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2942,15 +2942,14 @@ \subsection{Intra-package References}
29422942
statement looks for a top-level module with the given name.
29432943

29442944
When packages are structured into subpackages (as with the
2945-
\module{sound} package in the example), there's no shortcut to refer
2946-
to submodules of sibling packages - the full name of the subpackage
2947-
must be used. For example, if the module
2948-
\module{sound.filters.vocoder} needs to use the \module{echo} module
2949-
in the \module{sound.effects} package, it can use \code{from
2950-
sound.effects import echo}.
2945+
\module{sound} package in the example), you can use absolute
2946+
imports to refer to submodules of siblings packages.
2947+
For example, if the module \module{sound.filters.vocoder} needs to
2948+
use the \module{echo} module in the \module{sound.effects} package,
2949+
it can use \code{from sound.effects import echo}.
29512950

29522951
Starting with Python 2.5, in addition to the implicit relative imports
2953-
described above, you can write explicit relative imports with the
2952+
described above, you can also write explicit relative imports with the
29542953
\code{from module import name} form of import statement. These explicit
29552954
relative imports use leading dots to indicate the current and parent
29562955
packages involved in the relative import. From the \module{surround}

Lib/idlelib/run.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,16 @@ def flush_stdout():
193193
"""XXX How to do this now?"""
194194

195195
def exit():
196-
"""Exit subprocess, possibly after first deleting sys.exitfunc
196+
"""Exit subprocess, possibly after first clearing exit functions.
197197
198198
If config-main.cfg/.def 'General' 'delete-exitfunc' is True, then any
199-
sys.exitfunc will be removed before exiting. (VPython support)
199+
functions registered with atexit will be removed before exiting.
200+
(VPython support)
200201
201202
"""
202203
if no_exitfunc:
203-
del sys.exitfunc
204+
import atexit
205+
atexit._clear()
204206
sys.exit(0)
205207

206208
class MyRPCServer(rpc.RPCServer):

Lib/sgmllib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ def handle_entityref(self, name):
428428
if replacement is None:
429429
self.unknown_entityref(name)
430430
else:
431-
self.handle_data(self.convert_entityref(name))
431+
self.handle_data(replacement)
432432

433433
# Example -- handle data, should be overridden
434434
def handle_data(self, data):

Lib/test/test_dictcomps.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
2+
doctests = """
3+
4+
>>> k = "old value"
5+
>>> { k: None for k in range(10) }
6+
{0: None, 1: None, 2: None, 3: None, 4: None, 5: None, 6: None, 7: None, 8: None, 9: None}
7+
>>> k
8+
'old value'
9+
10+
>>> { k: k+10 for k in range(10) }
11+
{0: 10, 1: 11, 2: 12, 3: 13, 4: 14, 5: 15, 6: 16, 7: 17, 8: 18, 9: 19}
12+
13+
>>> g = "Global variable"
14+
>>> { k: g for k in range(10) }
15+
{0: 'Global variable', 1: 'Global variable', 2: 'Global variable', 3: 'Global variable', 4: 'Global variable', 5: 'Global variable', 6: 'Global variable', 7: 'Global variable', 8: 'Global variable', 9: 'Global variable'}
16+
17+
>>> { k: v for k in range(10) for v in range(10) if k == v }
18+
{0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9}
19+
20+
>>> { k: v for v in range(10) for k in range(v*9, v*10) }
21+
{9: 1, 18: 2, 19: 2, 27: 3, 28: 3, 29: 3, 36: 4, 37: 4, 38: 4, 39: 4, 45: 5, 46: 5, 47: 5, 48: 5, 49: 5, 54: 6, 55: 6, 56: 6, 57: 6, 58: 6, 59: 6, 63: 7, 64: 7, 65: 7, 66: 7, 67: 7, 68: 7, 69: 7, 72: 8, 73: 8, 74: 8, 75: 8, 76: 8, 77: 8, 78: 8, 79: 8, 81: 9, 82: 9, 83: 9, 84: 9, 85: 9, 86: 9, 87: 9, 88: 9, 89: 9}
22+
23+
>>> { x: y for y, x in ((1, 2), (3, 4)) } = 5 # doctest: +IGNORE_EXCEPTION_DETAIL
24+
Traceback (most recent call last):
25+
...
26+
SyntaxError: ...
27+
28+
>>> { x: y for y, x in ((1, 2), (3, 4)) } += 5 # doctest: +IGNORE_EXCEPTION_DETAIL
29+
Traceback (most recent call last):
30+
...
31+
SyntaxError: ...
32+
33+
"""
34+
35+
__test__ = {'doctests' : doctests}
36+
37+
def test_main(verbose=None):
38+
import sys
39+
from test import test_support
40+
from test import test_dictcomps
41+
test_support.run_doctest(test_dictcomps, verbose)
42+
43+
# verify reference counting
44+
if verbose and hasattr(sys, "gettotalrefcount"):
45+
import gc
46+
counts = [None] * 5
47+
for i in range(len(counts)):
48+
test_support.run_doctest(test_dictcomps, verbose)
49+
gc.collect()
50+
counts[i] = sys.gettotalrefcount()
51+
print(counts)
52+
53+
if __name__ == "__main__":
54+
test_main(verbose=True)

Modules/cStringIO.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,8 +664,11 @@ newIobject(PyObject *s) {
664664
char *buf;
665665
Py_ssize_t size;
666666

667-
if (PyObject_AsCharBuffer(s, (const char **)&buf, &size) != 0)
668-
return NULL;
667+
if (PyObject_AsReadBuffer(s, (const void **)&buf, &size)) {
668+
PyErr_Format(PyExc_TypeError, "expected read buffer, %.200s found",
669+
s->ob_type->tp_name);
670+
return NULL;
671+
}
669672

670673
self = PyObject_New(Iobject, &Itype);
671674
if (!self) return NULL;

Python/ast.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3112,6 +3112,7 @@ decode_utf8(const char **sPtr, const char *end, char* encoding)
31123112
return v;
31133113
}
31143114

3115+
#ifdef Py_USING_UNICODE
31153116
static PyObject *
31163117
decode_unicode(const char *s, size_t len, int rawmode, const char *encoding)
31173118
{
@@ -3174,6 +3175,7 @@ decode_unicode(const char *s, size_t len, int rawmode, const char *encoding)
31743175
Py_XDECREF(u);
31753176
return v;
31763177
}
3178+
#endif
31773179

31783180
/* s is a Python string literal, including the bracketing quote characters,
31793181
* and r &/or u prefixes (if any), and embedded escape sequences (if any).

0 commit comments

Comments
 (0)