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

Skip to content

Commit 0289b15

Browse files
committed
Merged revisions 73004,73439,73496,73509,73529,73564,73576-73577,73595-73596,73605 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r73004 | jeffrey.yasskin | 2009-05-28 22:44:31 -0500 (Thu, 28 May 2009) | 5 lines Fix nearly all compilation warnings under Apple gcc-4.0. Tested with OPT="-g -Wall -Wstrict-prototypes -Werror" in both --with-pydebug mode and --without. There's still a batch of non-prototype warnings in Xlib.h that I don't know how to fix. ........ r73439 | benjamin.peterson | 2009-06-15 19:29:31 -0500 (Mon, 15 Jun 2009) | 1 line don't mask encoding errors when decoding a string #6289 ........ r73496 | vinay.sajip | 2009-06-21 12:37:27 -0500 (Sun, 21 Jun 2009) | 1 line Issue #6314: logging.basicConfig() performs extra checks on the "level" argument. ........ r73509 | amaury.forgeotdarc | 2009-06-22 14:33:48 -0500 (Mon, 22 Jun 2009) | 2 lines #4490 Fix sample code run by "python -m xml.sax.xmlreader" ........ r73529 | r.david.murray | 2009-06-23 13:02:46 -0500 (Tue, 23 Jun 2009) | 4 lines Fix issue 5230 by having pydoc's safeimport check to see if the import error was thrown from itself in order to decide if the module can't be found. Thanks to Lucas Prado Melo for collaborating on the fix and tests. ........ r73564 | amaury.forgeotdarc | 2009-06-25 17:29:29 -0500 (Thu, 25 Jun 2009) | 6 lines #2016 Fix a crash in function call when the **kwargs dictionary is mutated during the function call setup. This even gives a slight speedup, probably because tuple allocation is faster than PyMem_NEW. ........ r73576 | benjamin.peterson | 2009-06-26 18:37:06 -0500 (Fri, 26 Jun 2009) | 1 line document is_declared_global() ........ r73577 | benjamin.peterson | 2009-06-27 09:16:23 -0500 (Sat, 27 Jun 2009) | 1 line link to extensive generator docs in the reference manual ........ r73595 | ezio.melotti | 2009-06-27 18:45:39 -0500 (Sat, 27 Jun 2009) | 1 line stmt and setup can contain multiple statements, see #5896 ........ r73596 | ezio.melotti | 2009-06-27 19:07:45 -0500 (Sat, 27 Jun 2009) | 1 line Fixed a wrong apostrophe ........ r73605 | georg.brandl | 2009-06-28 07:10:18 -0500 (Sun, 28 Jun 2009) | 1 line Remove stray pychecker directive. ........
1 parent cd3ffe6 commit 0289b15

15 files changed

Lines changed: 110 additions & 39 deletions

File tree

Doc/library/stdtypes.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,10 +583,18 @@ Once an iterator's :meth:`__next__` method raises :exc:`StopIteration`, it must
583583
continue to do so on subsequent calls. Implementations that do not obey this
584584
property are deemed broken.
585585

586+
587+
.. _generator-types:
588+
589+
Generator Types
590+
---------------
591+
586592
Python's :term:`generator`\s provide a convenient way to implement the iterator
587593
protocol. If a container object's :meth:`__iter__` method is implemented as a
588594
generator, it will automatically return an iterator object (technically, a
589595
generator object) supplying the :meth:`__iter__` and :meth:`__next__` methods.
596+
More information about generators can be found in :ref:`the documentation for
597+
the yield expression <yieldexpr>`.
590598

591599

592600
.. _typesseq:

Doc/library/symtable.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ Examining Symbol Tables
144144

145145
Return ``True`` if the symbol is global.
146146

147+
.. method:: is_declared_global()
148+
149+
Return ``True`` if the symbol is declared global with a global statement.
150+
147151
.. method:: is_local()
148152

149153
Return ``True`` if the symbol is local to its block.

Doc/library/timeit.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ The module defines the following public class:
2424

2525
The constructor takes a statement to be timed, an additional statement used for
2626
setup, and a timer function. Both statements default to ``'pass'``; the timer
27-
function is platform-dependent (see the module doc string). The statements may
28-
contain newlines, as long as they don't contain multi-line string literals.
27+
function is platform-dependent (see the module doc string). *stmt* and *setup*
28+
may also contain multiple statements separated by ``;`` or newlines, as long as
29+
they don't contain multi-line string literals.
2930

3031
To measure the execution time of the first statement, use the :meth:`timeit`
3132
method. The :meth:`repeat` method is a convenience to call :meth:`timeit`

Lib/email/mime/nonmultipart.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,9 @@
1414
class MIMENonMultipart(MIMEBase):
1515
"""Base class for MIME multipart/* type messages."""
1616

17-
__pychecker__ = 'unusednames=payload'
18-
1917
def attach(self, payload):
2018
# The public API prohibits attaching multiple subparts to MIMEBase
2119
# derived subtypes since none of them are, by definition, of content
2220
# type multipart/*
2321
raise errors.MultipartConversionError(
2422
'Cannot attach additional subparts to non-multipart/*')
25-
26-
del __pychecker__

Lib/pydoc.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class or function within a module or module in a package. If the
5454

5555
import sys, imp, os, re, inspect, builtins, pkgutil
5656
from reprlib import Repr
57+
from traceback import extract_tb as _extract_tb
5758
try:
5859
from collections import deque
5960
except ImportError:
@@ -292,9 +293,9 @@ def safeimport(path, forceload=0, cache={}):
292293
elif exc is SyntaxError:
293294
# A SyntaxError occurred before we could execute the module.
294295
raise ErrorDuringImport(value.filename, info)
295-
elif exc is ImportError and \
296-
str(value).lower().split()[:2] == ['no', 'module']:
297-
# The module was not found.
296+
elif exc is ImportError and _extract_tb(tb)[-1][2]=='safeimport':
297+
# The import error occurred directly in this function,
298+
# which means there is no such module in the path.
298299
return None
299300
else:
300301
# Some other error occurred during the importing process.

Lib/test/test_coding.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ def test_file_parse(self):
4949
unlink(TESTFN+".pyc")
5050
sys.path.pop(0)
5151

52+
def test_error_from_string(self):
53+
# See http://bugs.python.org/issue6289
54+
input = "# coding: ascii\n\N{SNOWMAN}".encode('utf-8')
55+
try:
56+
compile(input, "<string>", "exec")
57+
except SyntaxError as e:
58+
expected = "'ascii' codec can't decode byte 0xe2 in position 16: " \
59+
"ordinal not in range(128)"
60+
self.assertTrue(str(e).startswith(expected))
61+
else:
62+
self.fail("didn't raise")
63+
5264
def test_main():
5365
test.support.run_unittest(CodingTest)
5466

Lib/test/test_extcall.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,24 @@
243243
...
244244
TypeError: id() takes no keyword arguments
245245
246+
A corner case of keyword dictionary items being deleted during
247+
the function call setup. See <http://bugs.python.org/issue2016>.
248+
249+
>>> class Name(str):
250+
... def __eq__(self, other):
251+
... try:
252+
... del x[self]
253+
... except KeyError:
254+
... pass
255+
... return str.__eq__(self, other)
256+
... def __hash__(self):
257+
... return str.__hash__(self)
258+
259+
>>> x = {Name("a"):1, Name("b"):2}
260+
>>> def f(a, b):
261+
... print(a,b)
262+
>>> f(**x)
263+
1 2
246264
"""
247265

248266
from test import support

Lib/test/test_pydoc.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import sys
22
import os
3+
import os.path
34
import difflib
45
import subprocess
56
import re
67
import pydoc
78
import inspect
89
import unittest
910
import test.support
11+
from contextlib import contextmanager
12+
from test.support import TESTFN, forget, rmtree, EnvironmentVarGuard
1013

1114
from test import pydoc_mod
1215

@@ -183,6 +186,9 @@ class B(builtins.object)
183186
# output pattern for missing module
184187
missing_pattern = "no Python documentation found for '%s'"
185188

189+
# output pattern for module with bad imports
190+
badimport_pattern = "problem in %s - ImportError: No module named %s"
191+
186192
def run_pydoc(module_name, *args):
187193
"""
188194
Runs pydoc on the specified module. Returns the stripped
@@ -254,6 +260,42 @@ def test_not_here(self):
254260
self.assertEqual(expected, result,
255261
"documentation for missing module found")
256262

263+
def test_badimport(self):
264+
# This tests the fix for issue 5230, where if pydoc found the module
265+
# but the module had an internal import error pydoc would report no doc
266+
# found.
267+
modname = 'testmod_xyzzy'
268+
testpairs = (
269+
('i_am_not_here', 'i_am_not_here'),
270+
('test.i_am_not_here_either', 'i_am_not_here_either'),
271+
('test.i_am_not_here.neither_am_i', 'i_am_not_here.neither_am_i'),
272+
('i_am_not_here.{}'.format(modname), 'i_am_not_here.{}'.format(modname)),
273+
('test.{}'.format(modname), modname),
274+
)
275+
276+
@contextmanager
277+
def newdirinpath(dir):
278+
os.mkdir(dir)
279+
sys.path.insert(0, dir)
280+
yield
281+
sys.path.pop(0)
282+
rmtree(dir)
283+
284+
with newdirinpath(TESTFN), EnvironmentVarGuard() as env:
285+
env['PYTHONPATH'] = TESTFN
286+
fullmodname = os.path.join(TESTFN, modname)
287+
sourcefn = fullmodname + os.extsep + "py"
288+
for importstring, expectedinmsg in testpairs:
289+
f = open(sourcefn, 'w')
290+
f.write("import {}\n".format(importstring))
291+
f.close()
292+
try:
293+
result = run_pydoc(modname).decode("ascii")
294+
finally:
295+
forget(modname)
296+
expected = badimport_pattern % (modname, expectedinmsg)
297+
self.assertEqual(expected, result)
298+
257299
def test_input_strip(self):
258300
missing_module = " test.i_am_not_here "
259301
result = str(run_pydoc(missing_module), 'ascii')

Lib/xml/sax/expatreader.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,8 @@ def create_parser(*args, **kwargs):
407407
# ---
408408

409409
if __name__ == "__main__":
410-
import xml.sax
410+
import xml.sax.saxutils
411411
p = create_parser()
412-
p.setContentHandler(xml.sax.XMLGenerator())
412+
p.setContentHandler(xml.sax.saxutils.XMLGenerator())
413413
p.setErrorHandler(xml.sax.ErrorHandler())
414-
p.parse("../../../hamlet.xml")
414+
p.parse("http://www.ibiblio.org/xml/examples/shakespeare/hamlet.xml")

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ Andrew McNamara
482482
Craig McPheeters
483483
Lambert Meertens
484484
Bill van Melle
485+
Lucas Prado Melo
485486
Luke Mewburn
486487
Mike Meyer
487488
Steven Miale

0 commit comments

Comments
 (0)