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

Skip to content

Commit 3e4f055

Browse files
committed
Merged revisions 66045,66048-66049,66053,66060,66062-66063,66065,66067,66071-66074,66080,66082-66083,66090-66093,66097-66099,66103,66105,66110,66118 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r66045 | andrew.kuchling | 2008-08-26 19:27:18 -0500 (Tue, 26 Aug 2008) | 1 line Trim whitespace; add a few updates ........ r66048 | andrew.kuchling | 2008-08-26 19:45:02 -0500 (Tue, 26 Aug 2008) | 1 line Add an item and a note ........ r66049 | andrew.kuchling | 2008-08-26 21:12:18 -0500 (Tue, 26 Aug 2008) | 1 line Add various items ........ r66053 | georg.brandl | 2008-08-28 04:40:18 -0500 (Thu, 28 Aug 2008) | 2 lines #3711: .dll isn't a valid Python extension anymore. ........ r66060 | armin.rigo | 2008-08-29 16:21:52 -0500 (Fri, 29 Aug 2008) | 3 lines A collection of crashers, all variants of the idea of issue #3720. ........ r66062 | georg.brandl | 2008-08-30 04:49:36 -0500 (Sat, 30 Aug 2008) | 2 lines #3730: mention "server" attribute explicitly. ........ r66063 | georg.brandl | 2008-08-30 04:52:44 -0500 (Sat, 30 Aug 2008) | 2 lines #3716: fix typo. ........ r66065 | georg.brandl | 2008-08-30 05:03:09 -0500 (Sat, 30 Aug 2008) | 2 lines #3569: eval() also accepts "exec"able code objects. ........ r66067 | georg.brandl | 2008-08-30 08:17:39 -0500 (Sat, 30 Aug 2008) | 2 lines super() actually returns a super object. ........ r66071 | andrew.kuchling | 2008-08-30 10:19:57 -0500 (Sat, 30 Aug 2008) | 1 line Partial edits from revision and tidying pass ........ r66072 | andrew.kuchling | 2008-08-30 10:21:23 -0500 (Sat, 30 Aug 2008) | 1 line Tidy up some sentences ........ r66073 | andrew.kuchling | 2008-08-30 10:25:47 -0500 (Sat, 30 Aug 2008) | 1 line Correction from Antoine Pitrou: BufferedWriter and Reader support seek() ........ r66074 | andrew.kuchling | 2008-08-30 11:44:54 -0500 (Sat, 30 Aug 2008) | 1 line Edit four more sections ........ r66080 | georg.brandl | 2008-08-30 17:00:28 -0500 (Sat, 30 Aug 2008) | 2 lines Fix markup. ........ r66082 | andrew.kuchling | 2008-08-30 17:56:54 -0500 (Sat, 30 Aug 2008) | 1 line More edits; markup fixes ........ r66083 | andrew.kuchling | 2008-08-30 21:24:08 -0500 (Sat, 30 Aug 2008) | 1 line More edits ........ r66090 | andrew.kuchling | 2008-08-31 09:29:31 -0500 (Sun, 31 Aug 2008) | 1 line Edit the library section, rearranging items to flow better and making lots of edits ........ r66091 | andrew.kuchling | 2008-08-31 10:41:48 -0500 (Sun, 31 Aug 2008) | 1 line Last batch of edits; remove the 'other changes' section ........ r66092 | andrew.kuchling | 2008-08-31 10:48:44 -0500 (Sun, 31 Aug 2008) | 1 line Update patch/bug count ........ r66093 | gregory.p.smith | 2008-08-31 11:34:18 -0500 (Sun, 31 Aug 2008) | 3 lines issue3715: docstring representation of hex escaped string needs to be double escaped. ........ r66097 | benjamin.peterson | 2008-09-01 09:13:43 -0500 (Mon, 01 Sep 2008) | 4 lines #3703 unhelpful _fileio.FileIO error message when trying to open a directory Reviewer: Gregory P. Smith ........ r66098 | georg.brandl | 2008-09-01 09:15:55 -0500 (Mon, 01 Sep 2008) | 2 lines #3749: fix c'n'p errors. ........ r66099 | benjamin.peterson | 2008-09-01 09:18:30 -0500 (Mon, 01 Sep 2008) | 4 lines Fix compilation when --without-threads is given #3683 Reviewer: Georg Brandl, Benjamin Peterson ........ r66103 | vinay.sajip | 2008-09-01 09:30:10 -0500 (Mon, 01 Sep 2008) | 1 line logging: fixed lack of use of encoding attribute specified on a stream. ........ r66105 | vinay.sajip | 2008-09-01 09:33:59 -0500 (Mon, 01 Sep 2008) | 1 line logging: fixed lack of use of encoding attribute specified on a stream. ........ r66110 | vinay.sajip | 2008-09-01 10:08:07 -0500 (Mon, 01 Sep 2008) | 1 line Added section about configuring logging in a library. Thanks to Thomas Heller for the idea. ........ r66118 | vinay.sajip | 2008-09-01 12:44:14 -0500 (Mon, 01 Sep 2008) | 1 line Bug #3738: Documentation is now more accurate in describing handler close methods. ........
1 parent d098ff2 commit 3e4f055

13 files changed

Lines changed: 905 additions & 676 deletions

File tree

Doc/extending/windows.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,14 @@ described here are distributed with the Python sources in the
102102
and it should call :cfunc:`Py_InitModule` with the string ``"spam"`` as its
103103
first argument (use the minimal :file:`example.c` in this directory as a guide).
104104
By convention, it lives in a file called :file:`spam.c` or :file:`spammodule.c`.
105-
The output file should be called :file:`spam.dll` or :file:`spam.pyd` (the
106-
latter is supported to avoid confusion with a system library :file:`spam.dll` to
107-
which your module could be a Python interface) in Release mode, or
108-
:file:`spam_d.dll` or :file:`spam_d.pyd` in Debug mode.
105+
The output file should be called :file:`spam.pyd` (in Release mode) or
106+
:file:`spam_d.pyd` (in Debug mode). The extension :file:`.pyd` was chosen
107+
to avoid confusion with a system library :file:`spam.dll` to which your module
108+
could be a Python interface.
109+
110+
.. versionchanged:: 2.5
111+
Previously, file names like :file:`spam.dll` (in release mode) or
112+
:file:`spam_d.dll` (in debug mode) were also recognized.
109113

110114
Now your options are:
111115

Doc/library/codecs.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ It defines the following functions:
5151
Codec Interface). The functions/methods are expected to work in a stateless
5252
mode.
5353

54-
*incrementalencoder* and *incrementalencoder*: These have to be factory
54+
*incrementalencoder* and *incrementaldecoder*: These have to be factory
5555
functions providing the following interface:
5656

5757
``factory(errors='strict')``
5858

5959
The factory functions must return objects providing the interfaces defined by
60-
the base classes :class:`IncrementalEncoder` and :class:`IncrementalEncoder`,
60+
the base classes :class:`IncrementalEncoder` and :class:`IncrementalDecoder`,
6161
respectively. Incremental codecs can maintain state.
6262

6363
*streamreader* and *streamwriter*: These have to be factory functions providing
@@ -478,7 +478,7 @@ define in order to be compatible with the Python codec registry.
478478

479479
The *errors* argument will be assigned to an attribute of the same name.
480480
Assigning to this attribute makes it possible to switch between different error
481-
handling strategies during the lifetime of the :class:`IncrementalEncoder`
481+
handling strategies during the lifetime of the :class:`IncrementalDecoder`
482482
object.
483483

484484
The set of allowed values for the *errors* argument can be extended with

Doc/library/ctypes.rst

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
``ctypes`` is a foreign function library for Python. It provides C compatible
11-
data types, and allows calling functions in dlls/shared libraries. It can be
11+
data types, and allows calling functions in DLLs or shared libraries. It can be
1212
used to wrap these libraries in pure Python.
1313

1414

@@ -21,8 +21,8 @@ Note: The code samples in this tutorial use ``doctest`` to make sure that they
2121
actually work. Since some code samples behave differently under Linux, Windows,
2222
or Mac OS X, they contain doctest directives in comments.
2323

24-
Note: Some code sample references the ctypes :class:`c_int` type. This type is
25-
an alias to the :class:`c_long` type on 32-bit systems. So, you should not be
24+
Note: Some code samples reference the ctypes :class:`c_int` type. This type is
25+
an alias for the :class:`c_long` type on 32-bit systems. So, you should not be
2626
confused if :class:`c_long` is printed if you would expect :class:`c_int` ---
2727
they are actually the same type.
2828

@@ -32,8 +32,8 @@ they are actually the same type.
3232
Loading dynamic link libraries
3333
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3434

35-
``ctypes`` exports the *cdll*, and on Windows also *windll* and *oledll* objects
36-
to load dynamic link libraries.
35+
``ctypes`` exports the *cdll*, and on Windows *windll* and *oledll*
36+
objects, for loading dynamic link libraries.
3737

3838
You load libraries by accessing them as attributes of these objects. *cdll*
3939
loads libraries which export functions using the standard ``cdecl`` calling
@@ -315,7 +315,7 @@ property::
315315
>>> p = create_string_buffer("Hello", 10) # create a 10 byte buffer
316316
>>> print(sizeof(p), repr(p.raw))
317317
10 'Hello\x00\x00\x00\x00\x00'
318-
>>> p.value = "Hi"
318+
>>> p.value = "Hi"
319319
>>> print(sizeof(p), repr(p.raw))
320320
10 'Hi\x00lo\x00\x00\x00\x00\x00'
321321
>>>
@@ -906,7 +906,7 @@ other, and finally follow the pointer chain a few times::
906906
... p = p.next[0]
907907
...
908908
foo bar foo bar foo bar foo bar
909-
>>>
909+
>>>
910910

911911

912912
.. _ctypes-callback-functions:
@@ -2018,7 +2018,7 @@ Data types
20182018

20192019
.. method:: _CData.from_buffer_copy(source[, offset])
20202020

2021-
This method creates a ctypes instance, the buffer is copied from
2021+
This method creates a ctypes instance, copying the buffer from
20222022
the source object buffer which must be readable. The optional
20232023
``offset`` parameter specifies an offset into the source buffer
20242024
in bytes; the default is zero. If the source buffer is not
@@ -2033,13 +2033,13 @@ Data types
20332033

20342034
.. method:: from_param(obj)
20352035

2036-
This method adapts obj to a ctypes type. It is called with the actual
2037-
object used in a foreign function call, when the type is present in the
2038-
foreign functions :attr:`argtypes` tuple; it must return an object that
2039-
can be used as function call parameter.
2036+
This method adapts *obj* to a ctypes type. It is called with the actual
2037+
object used in a foreign function call when the type is present in the
2038+
foreign function's :attr:`argtypes` tuple; it must return an object that
2039+
can be used as a function call parameter.
20402040

2041-
All ctypes data types have a default implementation of this classmethod,
2042-
normally it returns ``obj`` if that is an instance of the type. Some
2041+
All ctypes data types have a default implementation of this classmethod
2042+
that normally returns ``obj`` if that is an instance of the type. Some
20432043
types accept other objects as well.
20442044

20452045

Doc/library/functions.rst

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,10 @@ are always available. They are listed here in alphabetical order.
372372
>>> eval('x+1')
373373
2
374374

375-
This function can also be used to execute arbitrary code objects (such as those
376-
created by :func:`compile`). In this case pass a code object instead of a
377-
string. The code object must have been compiled passing ``'eval'`` as the
378-
*kind* argument.
375+
This function can also be used to execute arbitrary code objects (such as
376+
those created by :func:`compile`). In this case pass a code object instead
377+
of a string. If the code object has been compiled with ``'exec'`` as the
378+
*kind* argument, :func:`eval`\'s return value will be ``None``.
379379

380380
Hints: dynamic execution of statements is supported by the :func:`exec`
381381
function. The :func:`globals` and :func:`locals` functions
@@ -1086,14 +1086,14 @@ are always available. They are listed here in alphabetical order.
10861086

10871087
.. XXX updated as per http://www.artima.com/weblogs/viewpost.jsp?thread=208549 but needs checking
10881088
1089-
Return the superclass of *type*.
1090-
1091-
Calling :func:`super()` without arguments is equivalent to
1092-
``super(this_class, first_arg)``. If called with one
1093-
argument the super object returned is unbound. If called with two
1094-
arguments and the second argument is an object, ``isinstance(obj,
1095-
type)`` must be true. If the second argument is a type,
1096-
``issubclass(type2, type)`` must be true.
1089+
1090+
Return a "super" object that acts like the superclass of *type*. If the
1091+
second argument is omitted the super object returned is unbound. If the
1092+
second argument is an object, ``isinstance(obj, type)`` must be true. If the
1093+
second argument is a type, ``issubclass(type2, type)`` must be
1094+
true. :func:`super` only works for :term:`new-style class`\es. Calling
1095+
:func:`super()` without arguments is equivalent to ``super(this_class,
1096+
first_arg)``.
10971097

10981098
A typical use for calling a cooperative superclass method is::
10991099

Doc/library/http.server.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ of which this module provides three different variants:
5656
Contains a tuple of the form ``(host, port)`` referring to the client's
5757
address.
5858

59+
.. attribute:: server
60+
61+
Contains the server instance.
62+
63+
5964
.. attribute:: command
6065

6166
Contains the command (request type). For example, ``'GET'``.

Doc/library/logging.rst

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,45 @@ You can see that the config file approach has a few advantages over the Python
420420
code approach, mainly separation of configuration and code and the ability of
421421
noncoders to easily modify the logging properties.
422422

423+
Configuring Logging for a Library
424+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
425+
426+
When developing a library which uses logging, some consideration needs to be
427+
given to its configuration. If the using application does not use logging, and
428+
library code makes logging calls, then a one-off message "No handlers could be
429+
found for logger X.Y.Z" is printed to the console. This message is intended
430+
to catch mistakes in logging configuration, but will confuse an application
431+
developer who is not aware of logging by the library.
432+
433+
In addition to documenting how a library uses logging, a good way to configure
434+
library logging so that it does not cause a spurious message is to add a
435+
handler which does nothing. This avoids the message being printed, since a
436+
handler will be found: it just doesn't produce any output. If the library user
437+
configures logging for application use, presumably that configuration will add
438+
some handlers, and if levels are suitably configured then logging calls made
439+
in library code will send output to those handlers, as normal.
440+
441+
A do-nothing handler can be simply defined as follows::
442+
443+
import logging
444+
445+
class NullHandler(logging.Handler):
446+
def emit(self, record):
447+
pass
448+
449+
An instance of this handler should be added to the top-level logger of the
450+
logging namespace used by the library. If all logging by a library *foo* is
451+
done using loggers with names matching "foo.x.y", then the code::
452+
453+
import logging
454+
455+
h = NullHandler()
456+
logging.getLogger("foo").addHandler(h)
457+
458+
should have the desired effect. If an organisation produces a number of
459+
libraries, then the logger name specified can be "orgname.foo" rather than
460+
just "foo".
461+
423462

424463
Logging Levels
425464
--------------
@@ -1440,8 +1479,10 @@ subclasses. However, the :meth:`__init__` method in subclasses needs to call
14401479

14411480
.. method:: Handler.close()
14421481

1443-
Tidy up any resources used by the handler. This version does nothing and is
1444-
intended to be implemented by subclasses.
1482+
Tidy up any resources used by the handler. This version does no output but
1483+
removes the handler from an internal list of handlers which is closed when
1484+
:func:`shutdown` is called. Subclasses should ensure that this gets called
1485+
from overridden :meth:`close` methods.
14451486

14461487

14471488
.. method:: Handler.handle(record)
@@ -1503,7 +1544,7 @@ and :meth:`flush` methods).
15031544

15041545
Flushes the stream by calling its :meth:`flush` method. Note that the
15051546
:meth:`close` method is inherited from :class:`Handler` and so does
1506-
nothing, so an explicit :meth:`flush` call may be needed at times.
1547+
no output, so an explicit :meth:`flush` call may be needed at times.
15071548

15081549

15091550
FileHandler
@@ -1821,7 +1862,7 @@ extensions for Python installed.
18211862
source of event log entries. However, if you do this, you will not be able
18221863
to see the events as you intended in the Event Log Viewer - it needs to be
18231864
able to access the registry to get the .dll name. The current version does
1824-
not do this (in fact it doesn't do anything).
1865+
not do this.
18251866

18261867

18271868
.. method:: emit(record)

Doc/library/math.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ The module also defines two mathematical constants:
290290
:exc:`OverflowError`, ``math.log(0L)`` may raise :exc:`ValueError` instead.
291291

292292
All functions return a quiet *NaN* if at least one of the args is *NaN*.
293-
Signaling *NaN*s raise an exception. The exception type still depends on the
293+
Signaling *NaN*\s raise an exception. The exception type still depends on the
294294
platform and libm implementation. It's usually :exc:`ValueError` for *EDOM*
295295
and :exc:`OverflowError` for errno *ERANGE*.
296296

0 commit comments

Comments
 (0)