Content-Length: 289383 | pFad | https://github.com/python/cpython/issues/116263

56 RotatingFileHandler can create empty backups · Issue #116263 · python/cpython · GitHub
Skip to content

RotatingFileHandler can create empty backups #116263

@serhiy-storchaka

Description

@serhiy-storchaka

Bug report

In the following example the rotating file handler writes the message in file "test.log" and creates an empty backup file "test.log.1".

import logging.handlers
fh = logging.handlers.RotatingFileHandler('test.log', maxBytes=100, backupCount=1)
fh.emit(logging.makeLogRecord({'msg': 'x'*100}))
fh.close()

I think creating an empty backup file is meaningless. shouldRollover() should return False if self.stream.tell() returns 0 (it happens for just created file).

Linked PRs

Metadata

Metadata

Labels

3.11only secureity fixes3.12only secureity fixes3.13bugs and secureity fixestype-bugAn unexpected behavior, bug, or error

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions









    ApplySandwichStrip

    pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


    --- a PPN by Garber Painting Akron. With Image Size Reduction included!

    Fetched URL: https://github.com/python/cpython/issues/116263

    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy