[issue42378] logging reopens file with same mode, possibly truncating

2022-01-07 Thread Vinay Sajip


Vinay Sajip  added the comment:


New changeset e35430bec528dfb1a653cd457ea58b5a08543632 by Miss Islington (bot) 
in branch '3.10':
[3.10] bpo-42378: fixed log truncation on logging shutdown (GH-27310) (GH-30468)
https://github.com/python/cpython/commit/e35430bec528dfb1a653cd457ea58b5a08543632


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42378] logging reopens file with same mode, possibly truncating

2022-01-07 Thread miss-islington


Change by miss-islington :


--
pull_requests: +28671
pull_request: https://github.com/python/cpython/pull/30468

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42378] logging reopens file with same mode, possibly truncating

2022-01-07 Thread Vinay Sajip


Vinay Sajip  added the comment:

I guess it got missed during the 3.10 beta cycle by not being backported - it 
might have needed to be cherry-picked. I'll see about getting it backported to 
3.10.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42378] logging reopens file with same mode, possibly truncating

2022-01-07 Thread Ned Deily


Change by Ned Deily :


--
nosy: +vinay.sajip

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42378] logging reopens file with same mode, possibly truncating

2022-01-07 Thread Dustin Oprea


Dustin Oprea  added the comment:

<- I'm intentionally using mode 'w' (to support development) and it's never 
been an issue until I recently refactored the project to be asynchronous. Now, 
every time I fail, I suddenly lose the logs. Not awesome.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42378] logging reopens file with same mode, possibly truncating

2022-01-07 Thread Dustin Oprea


Dustin Oprea  added the comment:

I believe I'm seeing this, still, in an async situation. It seems like the 
obvious culprit. 

When will this go out in a release? I'm on 3.10.1 from December (under Arch). 
The PR got merged to master in July but I went through all changelogs back to 
March and don't see it listed.

--
nosy: +Dustin.Oprea

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42378] logging reopens file with same mode, possibly truncating

2021-07-25 Thread miss-islington


miss-islington  added the comment:


New changeset 96cf5a63d2dbadaebf236362b4c7c09c51fda55c by andrei kulakov in 
branch 'main':
bpo-42378: fixed log truncation on logging shutdown (GH-27310)
https://github.com/python/cpython/commit/96cf5a63d2dbadaebf236362b4c7c09c51fda55c


--
nosy: +miss-islington

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42378] logging reopens file with same mode, possibly truncating

2021-07-23 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

I've put up a PR here: https://github.com/python/cpython/pull/27310/files

If this looks good, I will update the docs and add news entry.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42378] logging reopens file with same mode, possibly truncating

2021-07-23 Thread Andrei Kulakov


Change by Andrei Kulakov :


--
keywords: +patch
nosy: +andrei.avk
nosy_count: 1.0 -> 2.0
pull_requests: +25855
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/27310

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42378] logging reopens file with same mode, possibly truncating

2020-11-16 Thread Ed Catmur


New submission from Ed Catmur :

If a logging.FileHandler is configured with mode='w', or if logging.basicConfig 
is called with filemode='w' (as suggested by the Basic Logging Tutorial 
https://docs.python.org/3/howto/logging.html#logging-basic-tutorial)
and if some code logs during shutdown, after logging has closed its handlers 
(asyncio is prone to do this, e.g.),
then logging.FileHandler._open will reopen the log file with the same mode as 
it was originally opened with, potentially truncating it and losing valuable 
information:

import atexit
atexit.register(lambda: logging.info("so long"))
import logging
logging.basicConfig(filename='test.log', filemode='w', level=logging.INFO)
logging.info("super important stuff")

$ python truncate.py
$ cat test.log
INFO:root:so long

I have a hunch that the fix to issue 26789 will potentially make things worse, 
as previously at least there was a chance that logging had been fully unloaded 
so that the call to open would fail.

https://stackoverflow.com/questions/39838616/why-is-python-logging-framework-losing-messages

--
components: Library (Lib)
messages: 381146
nosy: ecatmur2
priority: normal
severity: normal
status: open
title: logging reopens file with same mode, possibly truncating
type: behavior
versions: Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com