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

Skip to content

Commit d3eb5a1

Browse files
committed
Merged revisions 61003-61033 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r61004 | georg.brandl | 2008-02-23 19:47:04 +0100 (Sat, 23 Feb 2008) | 2 lines Documentation coverage builder, part 1. ........ r61006 | andrew.kuchling | 2008-02-23 20:02:33 +0100 (Sat, 23 Feb 2008) | 1 line #1389051: IMAP module tries to read entire message in one chunk. Patch by Fredrik Lundh. ........ r61008 | andrew.kuchling | 2008-02-23 20:28:58 +0100 (Sat, 23 Feb 2008) | 1 line #1389051, #1092502: fix excessively large allocations when using read() on a socket ........ r61011 | jeffrey.yasskin | 2008-02-23 20:40:54 +0100 (Sat, 23 Feb 2008) | 13 lines Prevent classes like: class RunSelfFunction(object): def __init__(self): self.thread = threading.Thread(target=self._run) self.thread.start() def _run(self): pass from creating a permanent cycle between the object and the thread by having the Thread delete its references to the object when it completes. As an example of the effect of this bug, paramiko.Transport inherits from Thread to avoid it. ........ r61013 | jeffrey.yasskin | 2008-02-23 21:40:35 +0100 (Sat, 23 Feb 2008) | 3 lines Followup to r61011: Also avoid the reference cycle when the Thread's target raises an exception. ........ r61017 | georg.brandl | 2008-02-23 22:59:11 +0100 (Sat, 23 Feb 2008) | 2 lines #2101: fix removeAttribute docs. ........ r61018 | georg.brandl | 2008-02-23 23:05:38 +0100 (Sat, 23 Feb 2008) | 2 lines Add examples to modulefinder docs. Written for GHOP by Josip Dzolonga. ........ r61019 | georg.brandl | 2008-02-23 23:09:24 +0100 (Sat, 23 Feb 2008) | 2 lines Use os.closerange() in popen2. ........ r61020 | georg.brandl | 2008-02-23 23:14:02 +0100 (Sat, 23 Feb 2008) | 2 lines Use os.closerange(). ........ r61021 | georg.brandl | 2008-02-23 23:35:33 +0100 (Sat, 23 Feb 2008) | 3 lines In test_heapq and test_bisect, test both the Python and the C implementation. Originally written for GHOP by Josip Dzolonga, heavily patched by me. ........ r61024 | facundo.batista | 2008-02-23 23:54:12 +0100 (Sat, 23 Feb 2008) | 3 lines Added simple test case. Thanks Benjamin Peterson. ........ r61025 | georg.brandl | 2008-02-23 23:55:18 +0100 (Sat, 23 Feb 2008) | 2 lines #1825: correctly document msilib.add_data. ........ r61027 | georg.brandl | 2008-02-24 00:02:23 +0100 (Sun, 24 Feb 2008) | 2 lines #1826: allow dotted attribute paths in operator.attrgetter. ........ r61028 | georg.brandl | 2008-02-24 00:04:35 +0100 (Sun, 24 Feb 2008) | 2 lines #1506171: added operator.methodcaller(). ........ r61029 | georg.brandl | 2008-02-24 00:25:26 +0100 (Sun, 24 Feb 2008) | 2 lines Document import ./. threading issues. #1720705. ........ r61032 | georg.brandl | 2008-02-24 00:43:01 +0100 (Sun, 24 Feb 2008) | 2 lines Specify what kind of warning -3 emits. ........ r61033 | christian.heimes | 2008-02-24 00:59:45 +0100 (Sun, 24 Feb 2008) | 1 line MS Windows doesn't have mode_t but stat.st_mode is defined as unsigned short. ........
1 parent 05e8be1 commit d3eb5a1

20 files changed

Lines changed: 721 additions & 185 deletions

Demo/tkinter/guido/ShellWindow.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,7 @@ def spawn(prog, args):
121121
sys.stderr.write('popen2: bad write dup\n')
122122
if os.dup(c2pwrite) != 2:
123123
sys.stderr.write('popen2: bad write dup\n')
124-
for i in range(3, MAXFD):
125-
try:
126-
os.close(i)
127-
except:
128-
pass
124+
os.closerange(3, MAXFD)
129125
try:
130126
os.execvp(prog, args)
131127
finally:

Doc/Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ PAPER =
1212
ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees -D latex_paper_size=$(PAPER) \
1313
$(SPHINXOPTS) . build/$(BUILDER)
1414

15-
.PHONY: help checkout update build html web htmlhelp clean
15+
.PHONY: help checkout update build html web htmlhelp clean coverage
1616

1717
help:
1818
@echo "Please use \`make <target>' where <target> is one of"
@@ -22,6 +22,7 @@ help:
2222
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
2323
@echo " changes to make an overview over all changed/added/deprecated items"
2424
@echo " linkcheck to check all external links for integrity"
25+
@echo " coverage to check documentation coverage for library and C API"
2526

2627
checkout:
2728
@if [ ! -d tools/sphinx ]; then \
@@ -74,9 +75,13 @@ changes: build
7475

7576
linkcheck: BUILDER = linkcheck
7677
linkcheck: build
77-
@echo "Link check complete; look for any errors in the above output "\
78+
@echo "Link check complete; look for any errors in the above output " \
7879
"or in build/$(BUILDER)/output.txt"
7980

81+
coverage: BUILDER = coverage
82+
coverage: build
83+
@echo "Coverage finished; see c.txt and python.txt in build/coverage"
84+
8085
clean:
8186
-rm -rf build/*
8287
-rm -rf tools/sphinx

Doc/README.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ Available make targets are:
6464
deprecated items in the current version. This is meant as a help for the
6565
writer of the "What's New" document.
6666

67+
* "coverage", which builds a coverage overview for standard library modules
68+
and C API.
69+
6770
A "make update" updates the Subversion checkouts in `tools/`.
6871

6972

Doc/conf.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# General configuration
1414
# ---------------------
1515

16-
extensions = ['sphinx.addons.refcounting']
16+
extensions = ['sphinx.addons.refcounting', 'sphinx.addons.coverage']
1717

1818
# General substitutions.
1919
project = 'Python'
@@ -140,3 +140,39 @@
140140

141141
# Documents to append as an appendix to all manuals.
142142
latex_appendices = ['glossary', 'about', 'license', 'copyright']
143+
144+
# Options for the coverage checker
145+
# --------------------------------
146+
147+
# The coverage checker will ignore all modules/functions/classes whose names
148+
# match any of the following regexes (using re.match).
149+
coverage_ignore_modules = [
150+
r'[T|t][k|K]',
151+
r'Tix',
152+
r'distutils.*',
153+
]
154+
155+
coverage_ignore_functions = [
156+
'test($|_)',
157+
]
158+
159+
coverage_ignore_classes = [
160+
]
161+
162+
# Glob patterns for C source files for C API coverage, relative to this directory.
163+
coverage_c_path = [
164+
'../Include/*.h',
165+
]
166+
167+
# Regexes to find C items in the source files.
168+
coverage_c_regexes = {
169+
'cfunction': (r'^PyAPI_FUNC\(.*\)\s+([^_][\w_]+)'),
170+
'data': (r'^PyAPI_DATA\(.*\)\s+([^_][\w_]+)'),
171+
'macro': (r'^#define ([^_][\w_]+)\(.*\)[\s|\\]'),
172+
}
173+
174+
# The coverage checker will ignore all C items whose names match these regexes
175+
# (using re.match) -- the keys must be the same as in coverage_c_regexes.
176+
coverage_ignore_c_items = {
177+
# 'cfunction': [...]
178+
}

Doc/library/modulefinder.rst

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,65 @@ report of the imported modules will be printed.
4848

4949
Analyze the contents of the *pathname* file, which must contain Python code.
5050

51+
.. attribute:: ModuleFinder.modules
52+
53+
A dictionary mapping module names to modules. See :ref:`modulefinder-example`
54+
55+
56+
.. _modulefinder-example:
57+
58+
Example usage of :class:`ModuleFinder`
59+
--------------------------------------
60+
61+
The script that is going to get analyzed later on (bacon.py)::
62+
63+
import re, itertools
64+
65+
try:
66+
import baconhameggs
67+
except ImportError:
68+
pass
69+
70+
try:
71+
import guido.python.ham
72+
except ImportError:
73+
pass
74+
75+
76+
The script that will output the report of bacon.py::
77+
78+
from modulefinder import ModuleFinder
79+
80+
finder = ModuleFinder()
81+
finder.run_script('bacon.py')
82+
83+
print 'Loaded modules:'
84+
for name, mod in finder.modules.iteritems():
85+
print '%s: ' % name,
86+
print ','.join(mod.globalnames.keys()[:3])
87+
88+
print '-'*50
89+
print 'Modules not imported:'
90+
print '\n'.join(finder.badmodules.iterkeys())
91+
92+
Sample output (may vary depending on the architecture)::
93+
94+
Loaded modules:
95+
_types:
96+
copy_reg: _inverted_registry,_slotnames,__all__
97+
sre_compile: isstring,_sre,_optimize_unicode
98+
_sre:
99+
sre_constants: REPEAT_ONE,makedict,AT_END_LINE
100+
sys:
101+
re: __module__,finditer,_expand
102+
itertools:
103+
__main__: re,itertools,baconhameggs
104+
sre_parse: __getslice__,_PATTERNENDERS,SRE_FLAG_UNICODE
105+
array:
106+
types: __module__,IntType,TypeType
107+
---------------------------------------------------
108+
Modules not imported:
109+
guido.python.ham
110+
baconhameggs
111+
112+

Doc/library/msilib.rst

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ structures.
6565

6666
.. function:: init_database(name, schema, ProductName, ProductCode, ProductVersion, Manufacturer)
6767

68-
Create and return a new database *name*, initialize it with *schema*, and set
68+
Create and return a new database *name*, initialize it with *schema*, and set
6969
the properties *ProductName*, *ProductCode*, *ProductVersion*, and
7070
*Manufacturer*.
7171

@@ -77,13 +77,20 @@ structures.
7777
function returns.
7878

7979

80-
.. function:: add_data(database, records)
80+
.. function:: add_data(database, table, records)
8181

82-
Add all *records* to *database*. *records* should be a list of tuples, each one
83-
containing all fields of a record according to the schema of the table. For
84-
optional fields, ``None`` can be passed.
82+
Add all *records* to the table named *table* in *database*.
8583

86-
Field values can be integers, strings, or instances of the Binary class.
84+
The *table* argument must be one of the predefined tables in the MSI schema,
85+
e.g. ``'Feature'``, ``'File'``, ``'Component'``, ``'Dialog'``, ``'Control'``,
86+
etc.
87+
88+
*records* should be a list of tuples, each one containing all fields of a
89+
record according to the schema of the table. For optional fields,
90+
``None`` can be passed.
91+
92+
Field values can be int or long numbers, strings, or instances of the Binary
93+
class.
8794

8895

8996
.. class:: Binary(filename)

Doc/library/operator.rst

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,10 +419,12 @@ expect a function argument.
419419

420420
Return a callable object that fetches *attr* from its operand. If more than one
421421
attribute is requested, returns a tuple of attributes. After,
422-
``f=attrgetter('name')``, the call ``f(b)`` returns ``b.name``. After,
423-
``f=attrgetter('name', 'date')``, the call ``f(b)`` returns ``(b.name,
422+
``f = attrgetter('name')``, the call ``f(b)`` returns ``b.name``. After,
423+
``f = attrgetter('name', 'date')``, the call ``f(b)`` returns ``(b.name,
424424
b.date)``.
425425

426+
The attribute names can also contain dots; after ``f = attrgetter('date.month')``,
427+
the call ``f(b)`` returns ``b.date.month``.
426428

427429
.. function:: itemgetter(item[, args...])
428430

@@ -443,6 +445,15 @@ Examples::
443445
[('orange', 1), ('banana', 2), ('apple', 3), ('pear', 5)]
444446

445447

448+
.. function:: methodcaller(name[, args...])
449+
450+
Return a callable object that calls the method *name* on its operand. If
451+
additional arguments and/or keyword arguments are given, they will be given
452+
to the method as well. After ``f = methodcaller('name')``, the call ``f(b)``
453+
returns ``b.name()``. After ``f = methodcaller('name', 'foo', bar=1)``, the
454+
call ``f(b)`` returns ``b.name('foo', bar=1)``.
455+
456+
446457
.. _operator-map:
447458

448459
Mapping Operators to Functions

Doc/library/thread.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ In addition to these methods, lock objects can also be used via the
147147
exception will be received by an arbitrary thread. (When the :mod:`signal`
148148
module is available, interrupts always go to the main thread.)
149149

150+
* The import machinery is not thread safe. In general, an import may not
151+
have the side effect of importing a module, and only the main thread
152+
should import modules. Imports within or caused by a thread other than
153+
the main thread isn't safe.
154+
150155
* Calling :func:`sys.exit` or raising the :exc:`SystemExit` exception is
151156
equivalent to calling :func:`exit`.
152157

@@ -167,4 +172,3 @@ In addition to these methods, lock objects can also be used via the
167172
* When the main thread exits, it does not do any of its usual cleanup (except
168173
that :keyword:`try` ... :keyword:`finally` clauses are honored), and the
169174
standard I/O files are not flushed.
170-

Doc/library/threading.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,13 @@ the :meth:`setDaemon` method and retrieved with the :meth:`isDaemon` method.
555555
There is a "main thread" object; this corresponds to the initial thread of
556556
control in the Python program. It is not a daemon thread.
557557

558+
.. warning::
559+
560+
The import machinery is not thread safe. In general, an import may not
561+
have the side effect of importing a module, and only the main thread
562+
should import modules. Imports within or caused by a thread other than
563+
the main thread isn't safe.
564+
558565
There is the possibility that "dummy thread objects" are created. These are
559566
thread objects corresponding to "alien threads", which are threads of control
560567
started outside the threading module, such as directly from C code. Dummy

Doc/library/xml.dom.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,8 +641,8 @@ of that class.
641641

642642
.. method:: Element.removeAttribute(name)
643643

644-
Remove an attribute by name. No exception is raised if there is no matching
645-
attribute.
644+
Remove an attribute by name. If there is no matching attribute, a
645+
:exc:`NotFoundErr` is raised.
646646

647647

648648
.. method:: Element.removeAttributeNode(oldAttr)

0 commit comments

Comments
 (0)