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

Skip to content

Commit 37e6c54

Browse files
committed
Merge 3.1
2 parents 6f205ed + 5c1a0c9 commit 37e6c54

7 files changed

Lines changed: 56 additions & 35 deletions

File tree

Doc/c-api/intro.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,13 +511,12 @@ interpreter can only be used after the interpreter has been initialized.
511511
module: builtins
512512
module: __main__
513513
module: sys
514-
module: exceptions
515514
triple: module; search; path
516515
single: path (in module sys)
517516

518517
The basic initialization function is :c:func:`Py_Initialize`. This initializes
519518
the table of loaded modules, and creates the fundamental modules
520-
:mod:`builtins`, :mod:`__main__`, :mod:`sys`, and :mod:`exceptions`. It also
519+
:mod:`builtins`, :mod:`__main__`, and :mod:`sys`. It also
521520
initializes the module search path (``sys.path``).
522521

523522
.. index:: single: PySys_SetArgvEx()

Doc/documenting/markup.rst

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ The directives are:
152152

153153
Describes global data in a module, including both variables and values used
154154
as "defined constants." Class and object attributes are not documented
155-
using this environment.
155+
using this directive.
156156

157157
.. describe:: exception
158158

@@ -165,7 +165,7 @@ The directives are:
165165
parameters, enclosing optional parameters in brackets. Default values can be
166166
given if it enhances clarity. For example::
167167

168-
.. function:: Timer.repeat([repeat=3[, number=1000000]])
168+
.. function:: repeat([repeat=3[, number=1000000]])
169169

170170
Object methods are not documented using this directive. Bound object methods
171171
placed in the module namespace as part of the public interface of the module
@@ -217,13 +217,30 @@ The directives are:
217217

218218
Describes an object data attribute. The description should include
219219
information about the type of the data to be expected and whether it may be
220-
changed directly.
220+
changed directly. This directive should be nested in a class directive,
221+
like in this example::
222+
223+
.. class:: Spam
224+
225+
Description of the class.
226+
227+
.. data:: ham
228+
229+
Description of the attribute.
230+
231+
If is also possible to document an attribute outside of a class directive,
232+
for example if the documentation for different attributes and methods is
233+
split in multiple sections. The class name should then be included
234+
explicitly::
235+
236+
.. data:: Spam.eggs
221237

222238
.. describe:: method
223239

224240
Describes an object method. The parameters should not include the ``self``
225241
parameter. The description should include similar information to that
226-
described for ``function``.
242+
described for ``function``. This method should be nested in a class
243+
method, like in the example above.
227244

228245
.. describe:: decoratormethod
229246

Doc/library/dbm.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ the Oracle Berkeley DB.
3030
name, such as ``'dbm.ndbm'`` or ``'dbm.gnu'``.
3131

3232

33-
.. function:: open(filename, flag='r', mode=0o666)
33+
.. function:: open(file, flag='r', mode=0o666)
3434

35-
Open the database file *filename* and return a corresponding object.
35+
Open the database file *file* and return a corresponding object.
3636

3737
If the database file already exists, the :func:`whichdb` function is used to
3838
determine its type and the appropriate module is used; if it does not exist,

Lib/dbm/__init__.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,8 @@
2323
list = d.keys() # return a list of all existing keys (slow!)
2424
2525
Future versions may change the order in which implementations are
26-
tested for existence, add interfaces to other dbm-like
26+
tested for existence, and add interfaces to other dbm-like
2727
implementations.
28-
29-
The open function has an optional second argument. This can be 'r',
30-
for read-only access, 'w', for read-write access of an existing
31-
database, 'c' for read-write access to a new or existing database, and
32-
'n' for read-write access to a new database. The default is 'r'.
33-
34-
Note: 'r' and 'w' fail if the database doesn't exist; 'c' creates it
35-
only if it doesn't exist; and 'n' always creates a new database.
3628
"""
3729

3830
__all__ = ['open', 'whichdb', 'error']
@@ -53,7 +45,17 @@ class error(Exception):
5345
error = (error, IOError)
5446

5547

56-
def open(file, flag = 'r', mode = 0o666):
48+
def open(file, flag='r', mode=0o666):
49+
"""Open or create database at path given by *file*.
50+
51+
Optional argument *flag* can be 'r' (default) for read-only access, 'w'
52+
for read-write access of an existing database, 'c' for read-write access
53+
to a new or existing database, and 'n' for read-write access to a new
54+
database.
55+
56+
Note: 'r' and 'w' fail if the database doesn't exist; 'c' creates it
57+
only if it doesn't exist; and 'n' always creates a new database.
58+
"""
5759
global _defaultmod
5860
if _defaultmod is None:
5961
for name in _names:

Lib/distutils/command/sdist.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -294,17 +294,20 @@ def read_template(self):
294294
join_lines=1, lstrip_ws=1, rstrip_ws=1,
295295
collapse_join=1)
296296

297-
while True:
298-
line = template.readline()
299-
if line is None: # end of file
300-
break
301-
302-
try:
303-
self.filelist.process_template_line(line)
304-
except DistutilsTemplateError as msg:
305-
self.warn("%s, line %d: %s" % (template.filename,
306-
template.current_line,
307-
msg))
297+
try:
298+
while True:
299+
line = template.readline()
300+
if line is None: # end of file
301+
break
302+
303+
try:
304+
self.filelist.process_template_line(line)
305+
except DistutilsTemplateError as msg:
306+
self.warn("%s, line %d: %s" % (template.filename,
307+
template.current_line,
308+
msg))
309+
finally:
310+
template.close()
308311

309312
def prune_file_list(self):
310313
"""Prune off branches that might slip into the file list as created

Lib/distutils/tests/test_register.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def _no_way(prompt=''):
137137

138138
# let's see what the server received : we should
139139
# have 2 similar requests
140-
self.assertTrue(self.conn.reqs, 2)
140+
self.assertEqual(len(self.conn.reqs), 2)
141141
req1 = dict(self.conn.reqs[0].headers)
142142
req2 = dict(self.conn.reqs[1].headers)
143143

@@ -169,7 +169,7 @@ def test_registering(self):
169169
del register_module.input
170170

171171
# we should have send a request
172-
self.assertTrue(self.conn.reqs, 1)
172+
self.assertEqual(len(self.conn.reqs), 1)
173173
req = self.conn.reqs[0]
174174
headers = dict(req.headers)
175175
self.assertEqual(headers['Content-length'], '608')
@@ -187,7 +187,7 @@ def test_password_reset(self):
187187
del register_module.input
188188

189189
# we should have send a request
190-
self.assertTrue(self.conn.reqs, 1)
190+
self.assertEqual(len(self.conn.reqs), 1)
191191
req = self.conn.reqs[0]
192192
headers = dict(req.headers)
193193
self.assertEqual(headers['Content-length'], '290')

Lib/heapq.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def heappushpop(heap, item):
170170
return item
171171

172172
def heapify(x):
173-
"""Transform list into a heap, in-place, in O(len(heap)) time."""
173+
"""Transform list into a heap, in-place, in O(len(x)) time."""
174174
n = len(x)
175175
# Transform bottom-up. The largest index there's any point to looking at
176176
# is the largest with a child index in-range, so must have 2*i + 1 < n,
@@ -360,7 +360,7 @@ def nsmallest(n, iterable, key=None):
360360
return [min(chain(head, it))]
361361
return [min(chain(head, it), key=key)]
362362

363-
# When n>=size, it's faster to use sort()
363+
# When n>=size, it's faster to use sorted()
364364
try:
365365
size = len(iterable)
366366
except (TypeError, AttributeError):
@@ -398,7 +398,7 @@ def nlargest(n, iterable, key=None):
398398
return [max(chain(head, it))]
399399
return [max(chain(head, it), key=key)]
400400

401-
# When n>=size, it's faster to use sort()
401+
# When n>=size, it's faster to use sorted()
402402
try:
403403
size = len(iterable)
404404
except (TypeError, AttributeError):

0 commit comments

Comments
 (0)