[New-bugs-announce] [issue9512] logging.handlers.RotatingFileHandler - mode argument not respected

Friðrik Már Jónsson report at bugs.python.org
Wed Aug 4 17:38:59 CEST 2010

New submission from Friðrik Már Jónsson <fridrik at pyth.net>:

It seems to me that the ``mode`` keyword argument of
``logging.handlers.RotatingFileHandler`` is not respected.

Here is an example of opening a nonexistent file::

    Python 2.7 (r27:82500, Aug  4 2010, 15:10:49)
    [GCC 4.3.2] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import logging.handlers
    >>> handler = logging.handlers.RotatingFileHandler('nonexistent.log',
    ...     mode='a+', maxBytes=1000, backupCount=2)
    >>> handler.mode
    >>> handler.stream
    <open file '/home/fridrik/nonexistent.log', mode 'a' at 0x2aefbca796f0>

The docs do not mention any deviations from the behavior I expected
(``handler.stream`` having the mode specified as an argument to
``RotatingFileHandler``); only that "If mode is not specified, 'a' is used."

I've confirmed the same behavior on 2.5.2 and 2.6.2.  This happens regardless
of whether the file is being created or already exists.

components: Library (Lib)
messages: 112821
nosy: fridrik
priority: normal
severity: normal
status: open
title: logging.handlers.RotatingFileHandler - mode argument not respected
type: behavior
versions: Python 2.5, Python 2.6, Python 2.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list