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

Friðrik Már Jónsson report at bugs.python.org
Sun Aug 22 20:35:31 CEST 2010


Friðrik Már Jónsson <fridrik at pyth.net> added the comment:

I agree with your points on the triviality and potential harmfulness of allowing modes like 'b' and 'w'.

The '+' mode may be required for loggers that require headers or validation or positioning within an existing file (think XML). One example of such a format is the "Extended Log File Format" draft by the W3C which has seen widespread usage, despite being a draft.

With a format like the ELFF, it must be determined on opening an existing file (perhaps amongst other sanitary operations), whether its headers have already been written or whether they need to be.  It may also be desirable to simply check the file's size through its already open handler.

I can see an argument for not allowing this into the handler; handlers are perhaps not meant to support formats but much rather storage mechanisms.  Accepting this argument requires accepting the fact that libraries implementing such formats, using rotation and needing to read will need to write a handler from scratch for rotation support.

There may be more uses of different modes than my single example.  I see this boiling down to a matter of philosophy -- do we support usages we cannot foresee or do we admit certain features only when we've seen several valid examples of their use?

Perhaps we should also consider what harm is possibly done by allowing these modes, and whether harmful use is likelier to be attributed to bad architecture or programmer recklessness.

----------
status: pending -> open

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9512>
_______________________________________


More information about the Python-bugs-list mailing list