X Tutup
The Wayback Machine - https://web.archive.org/web/20240906232545/https://github.com/python/cpython/issues/116263
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RotatingFileHandler can create empty backups #116263

Closed
serhiy-storchaka opened this issue Mar 3, 2024 · 0 comments
Closed

RotatingFileHandler can create empty backups #116263

serhiy-storchaka opened this issue Mar 3, 2024 · 0 comments
Assignees
Labels
3.11 only security fixes 3.12 bugs and security fixes 3.13 bugs and security fixes type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

serhiy-storchaka commented Mar 3, 2024

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

@serhiy-storchaka serhiy-storchaka added type-bug An unexpected behavior, bug, or error 3.12 bugs and security fixes 3.13 bugs and security fixes labels Mar 3, 2024
@serhiy-storchaka serhiy-storchaka self-assigned this Mar 3, 2024
@serhiy-storchaka serhiy-storchaka added the 3.11 only security fixes label Mar 3, 2024
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Aug 7, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Aug 8, 2024
…ythonGH-122788)

(cherry picked from commit 6094c6f)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Aug 8, 2024
…ythonGH-122788)

(cherry picked from commit 6094c6f)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Yhg1s pushed a commit that referenced this issue Sep 2, 2024
…H-122788) (#122814)

gh-116263: Do not rollover empty files in RotatingFileHandler (GH-122788)
(cherry picked from commit 6094c6f)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
ambv pushed a commit that referenced this issue Sep 6, 2024
…H-122788) (#122815)

(cherry picked from commit 6094c6f)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@ambv ambv closed this as completed Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11 only security fixes 3.12 bugs and security fixes 3.13 bugs and security fixes type-bug An unexpected behavior, bug, or error
Projects
Development

No branches or pull requests

2 participants
X Tutup