Commit cd1b6a2b authored by Christian Heimes's avatar Christian Heimes

merge 2.7

parents 8f061ed3 4f59ed7a
...@@ -97,11 +97,11 @@ The output looks like this:: ...@@ -97,11 +97,11 @@ The output looks like this::
Multiple handlers and formatters Multiple handlers and formatters
-------------------------------- --------------------------------
Loggers are plain Python objects. The :func:`addHandler` method has no minimum Loggers are plain Python objects. The :meth:`~Logger.addHandler` method has no
or maximum quota for the number of handlers you may add. Sometimes it will be minimum or maximum quota for the number of handlers you may add. Sometimes it
beneficial for an application to log all messages of all severities to a text will be beneficial for an application to log all messages of all severities to a
file while simultaneously logging errors or above to the console. To set this text file while simultaneously logging errors or above to the console. To set
up, simply configure the appropriate handlers. The logging calls in the this up, simply configure the appropriate handlers. The logging calls in the
application code will remain unchanged. Here is a slight modification to the application code will remain unchanged. Here is a slight modification to the
previous simple module-based configuration example:: previous simple module-based configuration example::
...@@ -395,8 +395,9 @@ printed on the console; on the server side, you should see something like:: ...@@ -395,8 +395,9 @@ printed on the console; on the server side, you should see something like::
Note that there are some security issues with pickle in some scenarios. If Note that there are some security issues with pickle in some scenarios. If
these affect you, you can use an alternative serialization scheme by overriding these affect you, you can use an alternative serialization scheme by overriding
the :meth:`makePickle` method and implementing your alternative there, as the :meth:`~handlers.SocketHandler.makePickle` method and implementing your
well as adapting the above script to use your alternative serialization. alternative there, as well as adapting the above script to use your alternative
serialization.
.. _context-info: .. _context-info:
...@@ -404,6 +405,8 @@ well as adapting the above script to use your alternative serialization. ...@@ -404,6 +405,8 @@ well as adapting the above script to use your alternative serialization.
Adding contextual information to your logging output Adding contextual information to your logging output
---------------------------------------------------- ----------------------------------------------------
.. currentmodule:: logging
Sometimes you want logging output to contain contextual information in Sometimes you want logging output to contain contextual information in
addition to the parameters passed to the logging call. For example, in a addition to the parameters passed to the logging call. For example, in a
networked application, it may be desirable to log client-specific information networked application, it may be desirable to log client-specific information
...@@ -445,9 +448,9 @@ information in the delegated call. Here's a snippet from the code of ...@@ -445,9 +448,9 @@ information in the delegated call. Here's a snippet from the code of
msg, kwargs = self.process(msg, kwargs) msg, kwargs = self.process(msg, kwargs)
self.logger.debug(msg, *args, **kwargs) self.logger.debug(msg, *args, **kwargs)
The :meth:`process` method of :class:`LoggerAdapter` is where the contextual The :meth:`~LoggerAdapter.process` method of :class:`LoggerAdapter` is where the
information is added to the logging output. It's passed the message and contextual information is added to the logging output. It's passed the message
keyword arguments of the logging call, and it passes back (potentially) and keyword arguments of the logging call, and it passes back (potentially)
modified versions of these to use in the call to the underlying logger. The modified versions of these to use in the call to the underlying logger. The
default implementation of this method leaves the message alone, but inserts default implementation of this method leaves the message alone, but inserts
an 'extra' key in the keyword argument whose value is the dict-like object an 'extra' key in the keyword argument whose value is the dict-like object
...@@ -459,8 +462,8 @@ merged into the :class:`LogRecord` instance's __dict__, allowing you to use ...@@ -459,8 +462,8 @@ merged into the :class:`LogRecord` instance's __dict__, allowing you to use
customized strings with your :class:`Formatter` instances which know about customized strings with your :class:`Formatter` instances which know about
the keys of the dict-like object. If you need a different method, e.g. if you the keys of the dict-like object. If you need a different method, e.g. if you
want to prepend or append the contextual information to the message string, want to prepend or append the contextual information to the message string,
you just need to subclass :class:`LoggerAdapter` and override :meth:`process` you just need to subclass :class:`LoggerAdapter` and override
to do what you need. Here is a simple example:: :meth:`~LoggerAdapter.process` to do what you need. Here is a simple example::
class CustomAdapter(logging.LoggerAdapter): class CustomAdapter(logging.LoggerAdapter):
""" """
...@@ -569,25 +572,23 @@ threads in a single process *is* supported, logging to a single file from ...@@ -569,25 +572,23 @@ threads in a single process *is* supported, logging to a single file from
*multiple processes* is *not* supported, because there is no standard way to *multiple processes* is *not* supported, because there is no standard way to
serialize access to a single file across multiple processes in Python. If you serialize access to a single file across multiple processes in Python. If you
need to log to a single file from multiple processes, one way of doing this is need to log to a single file from multiple processes, one way of doing this is
to have all the processes log to a :class:`SocketHandler`, and have a separate to have all the processes log to a :class:`~handlers.SocketHandler`, and have a
process which implements a socket server which reads from the socket and logs separate process which implements a socket server which reads from the socket
to file. (If you prefer, you can dedicate one thread in one of the existing and logs to file. (If you prefer, you can dedicate one thread in one of the
processes to perform this function.) :ref:`This section <network-logging>` existing processes to perform this function.)
documents this approach in more detail and includes a working socket receiver :ref:`This section <network-logging>` documents this approach in more detail and
which can be used as a starting point for you to adapt in your own includes a working socket receiver which can be used as a starting point for you
applications. to adapt in your own applications.
If you are using a recent version of Python which includes the If you are using a recent version of Python which includes the
:mod:`multiprocessing` module, you could write your own handler which uses the :mod:`multiprocessing` module, you could write your own handler which uses the
:class:`Lock` class from this module to serialize access to the file from :class:`~multiprocessing.Lock` class from this module to serialize access to the
your processes. The existing :class:`FileHandler` and subclasses do not make file from your processes. The existing :class:`FileHandler` and subclasses do
use of :mod:`multiprocessing` at present, though they may do so in the future. not make use of :mod:`multiprocessing` at present, though they may do so in the
Note that at present, the :mod:`multiprocessing` module does not provide future. Note that at present, the :mod:`multiprocessing` module does not provide
working lock functionality on all platforms (see working lock functionality on all platforms (see
http://bugs.python.org/issue3770). http://bugs.python.org/issue3770).
.. currentmodule:: logging.handlers
Using file rotation Using file rotation
------------------- -------------------
...@@ -599,7 +600,7 @@ Sometimes you want to let a log file grow to a certain size, then open a new ...@@ -599,7 +600,7 @@ Sometimes you want to let a log file grow to a certain size, then open a new
file and log to that. You may want to keep a certain number of these files, and file and log to that. You may want to keep a certain number of these files, and
when that many files have been created, rotate the files so that the number of when that many files have been created, rotate the files so that the number of
files and the size of the files both remain bounded. For this usage pattern, the files and the size of the files both remain bounded. For this usage pattern, the
logging package provides a :class:`RotatingFileHandler`:: logging package provides a :class:`~handlers.RotatingFileHandler`::
import glob import glob
import logging import logging
...@@ -650,7 +651,7 @@ An example dictionary-based configuration ...@@ -650,7 +651,7 @@ An example dictionary-based configuration
Below is an example of a logging configuration dictionary - it's taken from Below is an example of a logging configuration dictionary - it's taken from
the `documentation on the Django project <https://docs.djangoproject.com/en/1.3/topics/logging/#configuring-logging>`_. the `documentation on the Django project <https://docs.djangoproject.com/en/1.3/topics/logging/#configuring-logging>`_.
This dictionary is passed to :func:`~logging.config.dictConfig` to put the configuration into effect:: This dictionary is passed to :func:`~config.dictConfig` to put the configuration into effect::
LOGGING = { LOGGING = {
'version': 1, 'version': 1,
......
...@@ -469,12 +469,13 @@ Handlers ...@@ -469,12 +469,13 @@ Handlers
:class:`~logging.Handler` objects are responsible for dispatching the :class:`~logging.Handler` objects are responsible for dispatching the
appropriate log messages (based on the log messages' severity) to the handler's appropriate log messages (based on the log messages' severity) to the handler's
specified destination. Logger objects can add zero or more handler objects to specified destination. :class:`Logger` objects can add zero or more handler
themselves with an :func:`addHandler` method. As an example scenario, an objects to themselves with an :meth:`~Logger.addHandler` method. As an example
application may want to send all log messages to a log file, all log messages scenario, an application may want to send all log messages to a log file, all
of error or higher to stdout, and all messages of critical to an email address. log messages of error or higher to stdout, and all messages of critical to an
This scenario requires three individual handlers where each handler is email address. This scenario requires three individual handlers where each
responsible for sending messages of a specific severity to a specific location. handler is responsible for sending messages of a specific severity to a specific
location.
The standard library includes quite a few handler types (see The standard library includes quite a few handler types (see
:ref:`useful-handlers`); the tutorials use mainly :class:`StreamHandler` and :ref:`useful-handlers`); the tutorials use mainly :class:`StreamHandler` and
...@@ -485,16 +486,17 @@ themselves with. The only handler methods that seem relevant for application ...@@ -485,16 +486,17 @@ themselves with. The only handler methods that seem relevant for application
developers who are using the built-in handler objects (that is, not creating developers who are using the built-in handler objects (that is, not creating
custom handlers) are the following configuration methods: custom handlers) are the following configuration methods:
* The :meth:`Handler.setLevel` method, just as in logger objects, specifies the * The :meth:`~Handler.setLevel` method, just as in logger objects, specifies the
lowest severity that will be dispatched to the appropriate destination. Why lowest severity that will be dispatched to the appropriate destination. Why
are there two :func:`setLevel` methods? The level set in the logger are there two :func:`setLevel` methods? The level set in the logger
determines which severity of messages it will pass to its handlers. The level determines which severity of messages it will pass to its handlers. The level
set in each handler determines which messages that handler will send on. set in each handler determines which messages that handler will send on.
* :func:`setFormatter` selects a Formatter object for this handler to use. * :meth:`~Handler.setFormatter` selects a Formatter object for this handler to
use.
* :func:`addFilter` and :func:`removeFilter` respectively configure and * :meth:`~Handler.addFilter` and :meth:`~Handler.removeFilter` respectively
deconfigure filter objects on handlers. configure and deconfigure filter objects on handlers.
Application code should not directly instantiate and use instances of Application code should not directly instantiate and use instances of
:class:`Handler`. Instead, the :class:`Handler` class is a base class that :class:`Handler`. Instead, the :class:`Handler` class is a base class that
...@@ -918,16 +920,16 @@ Logged messages are formatted for presentation through instances of the ...@@ -918,16 +920,16 @@ Logged messages are formatted for presentation through instances of the
use with the % operator and a dictionary. use with the % operator and a dictionary.
For formatting multiple messages in a batch, instances of For formatting multiple messages in a batch, instances of
:class:`BufferingFormatter` can be used. In addition to the format string (which :class:`~handlers.BufferingFormatter` can be used. In addition to the format
is applied to each message in the batch), there is provision for header and string (which is applied to each message in the batch), there is provision for
trailer format strings. header and trailer format strings.
When filtering based on logger level and/or handler level is not enough, When filtering based on logger level and/or handler level is not enough,
instances of :class:`Filter` can be added to both :class:`Logger` and instances of :class:`Filter` can be added to both :class:`Logger` and
:class:`Handler` instances (through their :meth:`addFilter` method). Before :class:`Handler` instances (through their :meth:`~Handler.addFilter` method).
deciding to process a message further, both loggers and handlers consult all Before deciding to process a message further, both loggers and handlers consult
their filters for permission. If any filter returns a false value, the message all their filters for permission. If any filter returns a false value, the
is not processed further. message is not processed further.
The basic :class:`Filter` functionality allows filtering by specific logger The basic :class:`Filter` functionality allows filtering by specific logger
name. If this feature is used, messages sent to the named logger and its name. If this feature is used, messages sent to the named logger and its
...@@ -945,19 +947,20 @@ in production. This is so that errors which occur while handling logging events ...@@ -945,19 +947,20 @@ in production. This is so that errors which occur while handling logging events
cause the application using logging to terminate prematurely. cause the application using logging to terminate prematurely.
:class:`SystemExit` and :class:`KeyboardInterrupt` exceptions are never :class:`SystemExit` and :class:`KeyboardInterrupt` exceptions are never
swallowed. Other exceptions which occur during the :meth:`emit` method of a swallowed. Other exceptions which occur during the :meth:`~Handler.emit` method
:class:`Handler` subclass are passed to its :meth:`handleError` method. of a :class:`Handler` subclass are passed to its :meth:`~Handler.handleError`
method.
The default implementation of :meth:`handleError` in :class:`Handler` checks The default implementation of :meth:`~Handler.handleError` in :class:`Handler`
to see if a module-level variable, :data:`raiseExceptions`, is set. If set, a checks to see if a module-level variable, :data:`raiseExceptions`, is set. If
traceback is printed to :data:`sys.stderr`. If not set, the exception is swallowed. set, a traceback is printed to :data:`sys.stderr`. If not set, the exception is
swallowed.
.. note:: The default value of :data:`raiseExceptions` is ``True``. This is .. note:: The default value of :data:`raiseExceptions` is ``True``. This is
because during development, you typically want to be notified of any because during development, you typically want to be notified of any
exceptions that occur. It's advised that you set :data:`raiseExceptions` to exceptions that occur. It's advised that you set :data:`raiseExceptions` to
``False`` for production usage. ``False`` for production usage.
.. currentmodule:: logging
.. _arbitrary-object-messages: .. _arbitrary-object-messages:
...@@ -967,11 +970,11 @@ Using arbitrary objects as messages ...@@ -967,11 +970,11 @@ Using arbitrary objects as messages
In the preceding sections and examples, it has been assumed that the message In the preceding sections and examples, it has been assumed that the message
passed when logging the event is a string. However, this is not the only passed when logging the event is a string. However, this is not the only
possibility. You can pass an arbitrary object as a message, and its possibility. You can pass an arbitrary object as a message, and its
:meth:`__str__` method will be called when the logging system needs to convert :meth:`~object.__str__` method will be called when the logging system needs to
it to a string representation. In fact, if you want to, you can avoid convert it to a string representation. In fact, if you want to, you can avoid
computing a string representation altogether - for example, the computing a string representation altogether - for example, the
:class:`SocketHandler` emits an event by pickling it and sending it over the :class:`~handlers.SocketHandler` emits an event by pickling it and sending it
wire. over the wire.
Optimization Optimization
...@@ -980,9 +983,10 @@ Optimization ...@@ -980,9 +983,10 @@ Optimization
Formatting of message arguments is deferred until it cannot be avoided. Formatting of message arguments is deferred until it cannot be avoided.
However, computing the arguments passed to the logging method can also be However, computing the arguments passed to the logging method can also be
expensive, and you may want to avoid doing it if the logger will just throw expensive, and you may want to avoid doing it if the logger will just throw
away your event. To decide what to do, you can call the :meth:`isEnabledFor` away your event. To decide what to do, you can call the
method which takes a level argument and returns true if the event would be :meth:`~Logger.isEnabledFor` method which takes a level argument and returns
created by the Logger for that level of call. You can write code like this:: true if the event would be created by the Logger for that level of call.
You can write code like this::
if logger.isEnabledFor(logging.DEBUG): if logger.isEnabledFor(logging.DEBUG):
logger.debug('Message with %s, %s', expensive_func1(), logger.debug('Message with %s, %s', expensive_func1(),
......
...@@ -104,8 +104,9 @@ in :mod:`logging` itself) and defining handlers which are declared either in ...@@ -104,8 +104,9 @@ in :mod:`logging` itself) and defining handlers which are declared either in
configurations. If no port is specified, the module's default configurations. If no port is specified, the module's default
:const:`DEFAULT_LOGGING_CONFIG_PORT` is used. Logging configurations will be :const:`DEFAULT_LOGGING_CONFIG_PORT` is used. Logging configurations will be
sent as a file suitable for processing by :func:`fileConfig`. Returns a sent as a file suitable for processing by :func:`fileConfig`. Returns a
:class:`Thread` instance on which you can call :meth:`start` to start the :class:`~threading.Thread` instance on which you can call
server, and which you can :meth:`join` when appropriate. To stop the server, :meth:`~threading.Thread.start` to start the server, and which you can
:meth:`~threading.Thread.join` when appropriate. To stop the server,
call :func:`stopListening`. call :func:`stopListening`.
To send a configuration to the socket, read in the configuration file and To send a configuration to the socket, read in the configuration file and
...@@ -169,11 +170,11 @@ otherwise, the context is used to determine what to instantiate. ...@@ -169,11 +170,11 @@ otherwise, the context is used to determine what to instantiate.
* *formatters* - the corresponding value will be a dict in which each * *formatters* - the corresponding value will be a dict in which each
key is a formatter id and each value is a dict describing how to key is a formatter id and each value is a dict describing how to
configure the corresponding Formatter instance. configure the corresponding :class:`~logging.Formatter` instance.
The configuring dict is searched for keys ``format`` and ``datefmt`` The configuring dict is searched for keys ``format`` and ``datefmt``
(with defaults of ``None``) and these are used to construct a (with defaults of ``None``) and these are used to construct a
:class:`logging.Formatter` instance. :class:`~logging.Formatter` instance.
* *filters* - the corresponding value will be a dict in which each key * *filters* - the corresponding value will be a dict in which each key
is a filter id and each value is a dict describing how to configure is a filter id and each value is a dict describing how to configure
...@@ -711,8 +712,9 @@ format string, with a comma separator. An example time in ISO8601 format is ...@@ -711,8 +712,9 @@ format string, with a comma separator. An example time in ISO8601 format is
The ``class`` entry is optional. It indicates the name of the formatter's class The ``class`` entry is optional. It indicates the name of the formatter's class
(as a dotted module and class name.) This option is useful for instantiating a (as a dotted module and class name.) This option is useful for instantiating a
:class:`Formatter` subclass. Subclasses of :class:`Formatter` can present :class:`~logging.Formatter` subclass. Subclasses of
exception tracebacks in an expanded or condensed format. :class:`~logging.Formatter` can present exception tracebacks in an expanded or
condensed format.
.. note:: Due to the use of :func:`eval` as described above, there are .. note:: Due to the use of :func:`eval` as described above, there are
potential security risks which result from using the :func:`listen` to send potential security risks which result from using the :func:`listen` to send
......
...@@ -53,8 +53,8 @@ and :meth:`flush` methods). ...@@ -53,8 +53,8 @@ and :meth:`flush` methods).
.. method:: flush() .. method:: flush()
Flushes the stream by calling its :meth:`flush` method. Note that the Flushes the stream by calling its :meth:`flush` method. Note that the
:meth:`close` method is inherited from :class:`Handler` and so does :meth:`close` method is inherited from :class:`~logging.Handler` and so
no output, so an explicit :meth:`flush` call may be needed at times. does no output, so an explicit :meth:`flush` call may be needed at times.
.. _file-handler: .. _file-handler:
...@@ -142,8 +142,8 @@ new stream. ...@@ -142,8 +142,8 @@ new stream.
This handler is not appropriate for use under Windows, because under Windows This handler is not appropriate for use under Windows, because under Windows
open log files cannot be moved or renamed - logging opens the files with open log files cannot be moved or renamed - logging opens the files with
exclusive locks - and so there is no need for such a handler. Furthermore, exclusive locks - and so there is no need for such a handler. Furthermore,
*ST_INO* is not supported under Windows; :func:`stat` always returns zero for *ST_INO* is not supported under Windows; :func:`~os.stat` always returns zero
this value. for this value.
.. class:: WatchedFileHandler(filename[,mode[, encoding[, delay]]]) .. class:: WatchedFileHandler(filename[,mode[, encoding[, delay]]])
...@@ -305,7 +305,8 @@ sends logging output to a network socket. The base class uses a TCP socket. ...@@ -305,7 +305,8 @@ sends logging output to a network socket. The base class uses a TCP socket.
binary format. If there is an error with the socket, silently drops the binary format. If there is an error with the socket, silently drops the
packet. If the connection was previously lost, re-establishes the packet. If the connection was previously lost, re-establishes the
connection. To unpickle the record at the receiving end into a connection. To unpickle the record at the receiving end into a
:class:`LogRecord`, use the :func:`makeLogRecord` function. :class:`~logging.LogRecord`, use the :func:`~logging.makeLogRecord`
function.
.. method:: handleError() .. method:: handleError()
...@@ -383,7 +384,8 @@ over UDP sockets. ...@@ -383,7 +384,8 @@ over UDP sockets.
Pickles the record's attribute dictionary and writes it to the socket in Pickles the record's attribute dictionary and writes it to the socket in
binary format. If there is an error with the socket, silently drops the binary format. If there is an error with the socket, silently drops the
packet. To unpickle the record at the receiving end into a packet. To unpickle the record at the receiving end into a
:class:`LogRecord`, use the :func:`makeLogRecord` function. :class:`~logging.LogRecord`, use the :func:`~logging.makeLogRecord`
function.
.. method:: makeSocket() .. method:: makeSocket()
......
...@@ -238,7 +238,7 @@ class CookieError(Exception): ...@@ -238,7 +238,7 @@ class CookieError(Exception):
# a two-way quoting algorithm. Any non-text character is translated # a two-way quoting algorithm. Any non-text character is translated
# into a 4 character sequence: a forward-slash followed by the # into a 4 character sequence: a forward-slash followed by the
# three-digit octal equivalent of the character. Any '\' or '"' is # three-digit octal equivalent of the character. Any '\' or '"' is
# quoted with a preceeding '\' slash. # quoted with a preceding '\' slash.
# #
# These are taken from RFC2068 and RFC2109. # These are taken from RFC2068 and RFC2109.
# _LegalChars is the list of chars which don't require "'s # _LegalChars is the list of chars which don't require "'s
......
...@@ -152,7 +152,7 @@ def _find_appropriate_compiler(_config_vars): ...@@ -152,7 +152,7 @@ def _find_appropriate_compiler(_config_vars):
# are not installed. # are not installed.
# #
# Futhermore, the compiler that can be used varies between # Futhermore, the compiler that can be used varies between
# Xcode releases. Upto Xcode 4 it was possible to use 'gcc-4.2' # Xcode releases. Up to Xcode 4 it was possible to use 'gcc-4.2'
# as the compiler, after that 'clang' should be used because # as the compiler, after that 'clang' should be used because
# gcc-4.2 is either not present, or a copy of 'llvm-gcc' that # gcc-4.2 is either not present, or a copy of 'llvm-gcc' that
# miscompiles Python. # miscompiles Python.
...@@ -192,7 +192,7 @@ def _find_appropriate_compiler(_config_vars): ...@@ -192,7 +192,7 @@ def _find_appropriate_compiler(_config_vars):
if cc != oldcc: if cc != oldcc:
# Found a replacement compiler. # Found a replacement compiler.
# Modify config vars using new compiler, if not already explictly # Modify config vars using new compiler, if not already explicitly
# overriden by an env variable, preserving additional arguments. # overriden by an env variable, preserving additional arguments.
for cv in _COMPILER_CONFIG_VARS: for cv in _COMPILER_CONFIG_VARS:
if cv in _config_vars and cv not in os.environ: if cv in _config_vars and cv not in os.environ:
...@@ -274,7 +274,7 @@ def _check_for_unavailable_sdk(_config_vars): ...@@ -274,7 +274,7 @@ def _check_for_unavailable_sdk(_config_vars):
# compile an extension using an SDK that is not present # compile an extension using an SDK that is not present
# on the current machine it is better to not use an SDK # on the current machine it is better to not use an SDK
# than to fail. This is particularly important with # than to fail. This is particularly important with
# the standalong Command Line Tools alternative to a # the standalone Command Line Tools alternative to a
# full-blown Xcode install since the CLT packages do not # full-blown Xcode install since the CLT packages do not
# provide SDKs. If the SDK is not present, it is assumed # provide SDKs. If the SDK is not present, it is assumed
# that the header files and dev libs have been installed # that the header files and dev libs have been installed
...@@ -378,7 +378,7 @@ def customize_config_vars(_config_vars): ...@@ -378,7 +378,7 @@ def customize_config_vars(_config_vars):
compilers are present, i.e. when installing pure compilers are present, i.e. when installing pure
Python dists. Customization of compiler paths Python dists. Customization of compiler paths
and detection of unavailable archs is deferred and detection of unavailable archs is deferred
until the first extention module build is until the first extension module build is
requested (in distutils.sysconfig.customize_compiler). requested (in distutils.sysconfig.customize_compiler).
Currently called from distutils.sysconfig Currently called from distutils.sysconfig
......
...@@ -222,7 +222,7 @@ class TimeRE(dict): ...@@ -222,7 +222,7 @@ class TimeRE(dict):
"""Convert a list to a regex string for matching a directive. """Convert a list to a regex string for matching a directive.
Want possible matching values to be from longest to shortest. This Want possible matching values to be from longest to shortest. This
prevents the possibility of a match occuring for a value that also prevents the possibility of a match occurring for a value that also
a substring of a larger value that should have matched (e.g., 'abc' a substring of a larger value that should have matched (e.g., 'abc'
matching when 'abcdef' should have been the match). matching when 'abcdef' should have been the match).
......
...@@ -123,7 +123,7 @@ It is best to first set all parameters, perhaps possibly the ...@@ -123,7 +123,7 @@ It is best to first set all parameters, perhaps possibly the
compression type, and then write audio frames using writeframesraw. compression type, and then write audio frames using writeframesraw.
When all frames have been written, either call writeframes('') or When all frames have been written, either call writeframes('') or
close() to patch up the sizes in the header. close() to patch up the sizes in the header.
Marks can be added anytime. If there are any marks, ypu must call Marks can be added anytime. If there are any marks, you must call
close() after all frames have been written. close() after all frames have been written.
The close() method is called automatically when the class instance The close() method is called automatically when the class instance
is destroyed. is destroyed.
......
...@@ -220,7 +220,7 @@ class Calendar(object): ...@@ -220,7 +220,7 @@ class Calendar(object):
def yeardatescalendar(self, year, width=3): def yeardatescalendar(self, year, width=3):
""" """
Return the data for the specified year ready for formatting. The return Return the data for the specified year ready for formatting. The return
value is a list of month rows. Each month row contains upto width months. value is a list of month rows. Each month row contains up to width months.
Each month contains between 4 and 6 weeks and each week contains 1-7 Each month contains between 4 and 6 weeks and each week contains 1-7
days. Days are datetime.date objects. days. Days are datetime.date objects.
""" """
......
...@@ -125,7 +125,7 @@ def order_blocks(start_block, exit_block): ...@@ -125,7 +125,7 @@ def order_blocks(start_block, exit_block):
# Make sure every block appears in dominators, even if no # Make sure every block appears in dominators, even if no
# other block must precede it. # other block must precede it.
dominators.setdefault(b, set()) dominators.setdefault(b, set())
# preceeding blocks dominate following blocks # preceding blocks dominate following blocks
for c in b.get_followers(): for c in b.get_followers():
while 1: while 1:
dominators.setdefault(c, set()).add(b) dominators.setdefault(c, set()).add(b)
......
...@@ -586,7 +586,7 @@ class SequenceMatcher: ...@@ -586,7 +586,7 @@ class SequenceMatcher:
def get_grouped_opcodes(self, n=3): def get_grouped_opcodes(self, n=3):
""" Isolate change clusters by eliminating ranges with no changes. """ Isolate change clusters by eliminating ranges with no changes.
Return a generator of groups with upto n lines of context. Return a generator of groups with up to n lines of context.
Each group is in the same format as returned by get_opcodes(). Each group is in the same format as returned by get_opcodes().
>>> from pprint import pprint >>> from pprint import pprint
...@@ -1361,7 +1361,7 @@ def _mdiff(fromlines, tolines, context=None, linejunk=None, ...@@ -1361,7 +1361,7 @@ def _mdiff(fromlines, tolines, context=None, linejunk=None,
linejunk -- passed on to ndiff (see ndiff documentation) linejunk -- passed on to ndiff (see ndiff documentation)
charjunk -- passed on to ndiff (see ndiff documentation) charjunk -- passed on to ndiff (see ndiff documentation)
This function returns an interator which returns a tuple: This function returns an iterator which returns a tuple:
(from line tuple, to line tuple, boolean flag) (from line tuple, to line tuple, boolean flag)
from/to line tuple -- (line num, line text) from/to line tuple -- (line num, line text)
...@@ -1963,7 +1963,7 @@ class HtmlDiff(object): ...@@ -1963,7 +1963,7 @@ class HtmlDiff(object):
self._make_prefix() self._make_prefix()
# change tabs to spaces before it gets more difficult after we insert # change tabs to spaces before it gets more difficult after we insert
# markkup # markup
fromlines,tolines = self._tab_newline_replace(fromlines,tolines) fromlines,tolines = self._tab_newline_replace(fromlines,tolines)
# create diffs iterator which generates side by side from/to data # create diffs iterator which generates side by side from/to data
......
...@@ -424,7 +424,7 @@ class Example: ...@@ -424,7 +424,7 @@ class Example:
zero-based, with respect to the beginning of the DocTest. zero-based, with respect to the beginning of the DocTest.
- indent: The example's indentation in the DocTest string. - indent: The example's indentation in the DocTest string.
I.e., the number of space characters that preceed the I.e., the number of space characters that precede the
example's first prompt. example's first prompt.
- options: A dictionary mapping from option flags to True or - options: A dictionary mapping from option flags to True or
...@@ -895,7 +895,7 @@ class DocTestFinder: ...@@ -895,7 +895,7 @@ class DocTestFinder:
if '__name__' not in globs: if '__name__' not in globs:
globs['__name__'] = '__main__' # provide a default module name globs['__name__'] = '__main__' # provide a default module name
# Recursively expore `obj`, extracting DocTests. # Recursively explore `obj`, extracting DocTests.
tests = [] tests = []
self._find(tests, obj, name, module, source_lines, globs, {}) self._find(tests, obj, name, module, source_lines, globs, {})
# Sort the tests by alpha order of names, for consistency in # Sort the tests by alpha order of names, for consistency in
......
...@@ -22,7 +22,7 @@ def exists(path): ...@@ -22,7 +22,7 @@ def exists(path):
# This follows symbolic links, so both islink() and isdir() can be true # This follows symbolic links, so both islink() and isdir() can be true
# for the same path ono systems that support symlinks # for the same path on systems that support symlinks
def isfile(path): def isfile(path):
"""Test whether a path is a regular file""" """Test whether a path is a regular file"""
try: try:
......
...@@ -165,7 +165,7 @@ def isgenerator(object): ...@@ -165,7 +165,7 @@ def isgenerator(object):
"""Return true if the object is a generator. """Return true if the object is a generator.
Generator objects provide these attributes: Generator objects provide these attributes:
__iter__ defined to support interation over container __iter__ defined to support iteration over container
close raises a new GeneratorExit exception inside the close raises a new GeneratorExit exception inside the
generator to terminate the iteration generator to terminate the iteration
gi_code code object gi_code code object
......
...@@ -1233,7 +1233,7 @@ class TurtleScreen(TurtleScreenBase): ...@@ -1233,7 +1233,7 @@ class TurtleScreen(TurtleScreenBase):
self._delayvalue = int(delay) self._delayvalue = int(delay)
def _incrementudc(self): def _incrementudc(self):
"""Increment upadate counter.""" """Increment update counter."""
if not TurtleScreen._RUNNING: if not TurtleScreen._RUNNING:
TurtleScreen._RUNNNING = True TurtleScreen._RUNNNING = True
raise Terminator raise Terminator
...@@ -2439,7 +2439,7 @@ class RawTurtle(TPen, TNavigator): ...@@ -2439,7 +2439,7 @@ class RawTurtle(TPen, TNavigator):
self.screen = TurtleScreen(canvas) self.screen = TurtleScreen(canvas)
RawTurtle.screens.append(self.screen) RawTurtle.screens.append(self.screen)
else: else:
raise TurtleGraphicsError("bad cavas argument %s" % canvas) raise TurtleGraphicsError("bad canvas argument %s" % canvas)
screen = self.screen screen = self.screen
TNavigator.__init__(self, screen.mode()) TNavigator.__init__(self, screen.mode())
...@@ -2684,7 +2684,7 @@ class RawTurtle(TPen, TNavigator): ...@@ -2684,7 +2684,7 @@ class RawTurtle(TPen, TNavigator):
def shapesize(self, stretch_wid=None, stretch_len=None, outline=None): def shapesize(self, stretch_wid=None, stretch_len=None, outline=None):
"""Set/return turtle's stretchfactors/outline. Set resizemode to "user". """Set/return turtle's stretchfactors/outline. Set resizemode to "user".
Optinonal arguments: Optional arguments:
stretch_wid : positive number stretch_wid : positive number
stretch_len : positive number stretch_len : positive number
outline : positive number outline : positive number
...@@ -2975,7 +2975,7 @@ class RawTurtle(TPen, TNavigator): ...@@ -2975,7 +2975,7 @@ class RawTurtle(TPen, TNavigator):
def _goto(self, end): def _goto(self, end):
"""Move the pen to the point end, thereby drawing a line """Move the pen to the point end, thereby drawing a line
if pen is down. All other methodes for turtle movement depend if pen is down. All other methods for turtle movement depend
on this one. on this one.
""" """
## Version mit undo-stuff ## Version mit undo-stuff
......
...@@ -516,7 +516,7 @@ class ModuleFinder: ...@@ -516,7 +516,7 @@ class ModuleFinder:
# Print modules that may be missing, but then again, maybe not... # Print modules that may be missing, but then again, maybe not...
if maybe: if maybe:
print print
print "Submodules thay appear to be missing, but could also be", print "Submodules that appear to be missing, but could also be",
print "global names in the parent package:" print "global names in the parent package:"
for name in maybe: for name in maybe:
mods = self.badmodules[name].keys() mods = self.badmodules[name].keys()
......
...@@ -367,7 +367,7 @@ else: ...@@ -367,7 +367,7 @@ else:
def main(): def main():
''' '''
Run code specifed by data received over pipe Run code specified by data received over pipe
''' '''
assert is_forking(sys.argv) assert is_forking(sys.argv)
......
...@@ -1471,7 +1471,7 @@ class OptionParser (OptionContainer): ...@@ -1471,7 +1471,7 @@ class OptionParser (OptionContainer):
"""_match_long_opt(opt : string) -> string """_match_long_opt(opt : string) -> string
Determine which long option string 'opt' matches, ie. which one Determine which long option string 'opt' matches, ie. which one
it is an unambiguous abbrevation for. Raises BadOptionError if it is an unambiguous abbreviation for. Raises BadOptionError if
'opt' doesn't unambiguously match any long option string. 'opt' doesn't unambiguously match any long option string.
""" """
return _match_abbrev(opt, self._long_opt) return _match_abbrev(opt, self._long_opt)
......
...@@ -1095,7 +1095,7 @@ command with a 'global' command, e.g.: ...@@ -1095,7 +1095,7 @@ command with a 'global' command, e.g.:
def help_run(self): def help_run(self):
print """run [args...] print """run [args...]
Restart the debugged python program. If a string is supplied, it is Restart the debugged python program. If a string is supplied, it is
splitted with "shlex" and the result is used as the new sys.argv. split with "shlex" and the result is used as the new sys.argv.
History, breakpoints, actions and debugger options are preserved. History, breakpoints, actions and debugger options are preserved.
"restart" is an alias for "run".""" "restart" is an alias for "run"."""
......
...@@ -804,7 +804,7 @@ stackslice = StackObject( ...@@ -804,7 +804,7 @@ stackslice = StackObject(
obtype=StackObject, obtype=StackObject,
doc="""An object representing a contiguous slice of the stack. doc="""An object representing a contiguous slice of the stack.
This is used in conjuction with markobject, to represent all This is used in conjunction with markobject, to represent all
of the stack following the topmost markobject. For example, of the stack following the topmost markobject. For example,
the POP_MARK opcode changes the stack from the POP_MARK opcode changes the stack from
...@@ -1929,7 +1929,7 @@ def dis(pickle, out=None, memo=None, indentlevel=4): ...@@ -1929,7 +1929,7 @@ def dis(pickle, out=None, memo=None, indentlevel=4):
stack = [] # crude emulation of unpickler stack stack = [] # crude emulation of unpickler stack
if memo is None: if memo is None:
memo = {} # crude emulation of unpicker memo memo = {} # crude emulation of unpickler memo
maxproto = -1 # max protocol number seen maxproto = -1 # max protocol number seen
markstack = [] # bytecode positions of MARK opcodes markstack = [] # bytecode positions of MARK opcodes
indentchunk = ' ' * indentlevel indentchunk = ' ' * indentlevel
......
...@@ -228,7 +228,7 @@ def _dist_try_harder(distname,version,id): ...@@ -228,7 +228,7 @@ def _dist_try_harder(distname,version,id):
return 'OpenLinux',pkg[1],id return 'OpenLinux',pkg[1],id
if os.path.isdir('/usr/lib/setup'): if os.path.isdir('/usr/lib/setup'):
# Check for slackware verson tag file (thanks to Greg Andruk) # Check for slackware version tag file (thanks to Greg Andruk)
verfiles = os.listdir('/usr/lib/setup') verfiles = os.listdir('/usr/lib/setup')
for n in range(len(verfiles)-1, -1, -1): for n in range(len(verfiles)-1, -1, -1):
if verfiles[n][:14] != 'slack-version-': if verfiles[n][:14] != 'slack-version-':
...@@ -280,7 +280,7 @@ def _parse_release_file(firstline): ...@@ -280,7 +280,7 @@ def _parse_release_file(firstline):
if m is not None: if m is not None:
return tuple(m.groups()) return tuple(m.groups())
# Unkown format... take the first two words # Unknown format... take the first two words
l = string.split(string.strip(firstline)) l = string.split(string.strip(firstline))
if l: if l:
version = l[0] version = l[0]
...@@ -800,7 +800,7 @@ def mac_ver(release='',versioninfo=('','',''),machine=''): ...@@ -800,7 +800,7 @@ def mac_ver(release='',versioninfo=('','',''),machine=''):
versioninfo, machine) with versioninfo being a tuple (version, versioninfo, machine) with versioninfo being a tuple (version,
dev_stage, non_release_version). dev_stage, non_release_version).
Entries which cannot be determined are set to the paramter values Entries which cannot be determined are set to the parameter values
which default to ''. All tuple entries are strings. which default to ''. All tuple entries are strings.
""" """
......
...@@ -321,7 +321,7 @@ else: ...@@ -321,7 +321,7 @@ else:
hostname - the hostname of the pop3 over ssl server hostname - the hostname of the pop3 over ssl server
port - port number port - port number
keyfile - PEM formatted file that countains your private key keyfile - PEM formatted file that contains your private key
certfile - PEM formatted certificate chain file certfile - PEM formatted certificate chain file
See the methods of the parent class POP3 for more documentation. See the methods of the parent class POP3 for more documentation.
......
...@@ -116,7 +116,7 @@ class Completer: ...@@ -116,7 +116,7 @@ class Completer:
"""Compute matches when text contains a dot. """Compute matches when text contains a dot.
Assuming the text is of the form NAME.NAME....[NAME], and is Assuming the text is of the form NAME.NAME....[NAME], and is
evaluatable in self.namespace, it will be evaluated and its attributes evaluable in self.namespace, it will be evaluated and its attributes
(as revealed by dir()) are used as possible completions. (For class (as revealed by dir()) are used as possible completions. (For class
instances, class members are also considered.) instances, class members are also considered.)
......
...@@ -143,7 +143,7 @@ Exceptions raised in the child process, before the new program has ...@@ -143,7 +143,7 @@ Exceptions raised in the child process, before the new program has
started to execute, will be re-raised in the parent. Additionally, started to execute, will be re-raised in the parent. Additionally,
the exception object will have one extra attribute called the exception object will have one extra attribute called
'child_traceback', which is a string containing traceback information 'child_traceback', which is a string containing traceback information
from the childs point of view. from the child's point of view.
The most common exception raised is OSError. This occurs, for The most common exception raised is OSError. This occurs, for
example, when trying to execute a non-existent file. Applications example, when trying to execute a non-existent file. Applications
......
...@@ -330,7 +330,7 @@ class ExtractError(TarError): ...@@ -330,7 +330,7 @@ class ExtractError(TarError):
"""General exception for extract errors.""" """General exception for extract errors."""
pass pass
class ReadError(TarError): class ReadError(TarError):
"""Exception for unreadble tar archives.""" """Exception for unreadable tar archives."""
pass pass
class CompressionError(TarError): class CompressionError(TarError):
"""Exception for unavailable compression methods.""" """Exception for unavailable compression methods."""
......
...@@ -1015,6 +1015,7 @@ Mikhail Terekhov ...@@ -1015,6 +1015,7 @@ Mikhail Terekhov
Victor Terrón Victor Terrón
Richard M. Tew Richard M. Tew
Tobias Thelen Tobias Thelen
Févry Thibault
Lowe Thiderman Lowe Thiderman
Nicolas M. Thiéry Nicolas M. Thiéry
James Thomas James Thomas
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment