[issue22996] Order of _io objects finalization can lose data in reference cycles

2021-11-27 Thread Irit Katriel


Irit Katriel  added the comment:

Reproduced on 3.11.

--
nosy: +iritkatriel
type:  -> behavior
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 3.4, Python 3.5

___
Python tracker 

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



[issue22996] Order of _io objects finalization can lose data in reference cycles

2014-12-05 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


Added file: http://bugs.python.org/file37371/gcgzipio.py

___
Python tracker 

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



[issue22996] Order of _io objects finalization can lose data in reference cycles

2014-12-05 Thread STINNER Victor

Changes by STINNER Victor :


--
nosy: +haypo

___
Python tracker 

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



[issue22996] Order of _io objects finalization can lose data in reference cycles

2014-12-05 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Note that the same issue is exist with gzip, bz2, lzma, tarfile and zipfile (or 
even worse).

--

___
Python tracker 

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



[issue22996] Order of _io objects finalization can lose data in reference cycles

2014-12-04 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I think that reference loop breaker should be smarter. If we have a loop

A ⇄ B → C → D

then the order of the finalization of A and B is not defined, but B should be 
finalized before C and C before D. This should fix unintentional issues with 
chained io classes because they have no back references.

--

___
Python tracker 

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



[issue22996] Order of _io objects finalization can lose data in reference cycles

2014-12-04 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I was thinking about weak backrefs. It's specialized for the io module but it 
would be fairly reliable, and not too complicated to implement.

--

___
Python tracker 

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



[issue22996] Order of _io objects finalization can lose data in reference cycles

2014-12-04 Thread Josh Rosenberg

Josh Rosenberg added the comment:

What is the proposal? Global registration of file objects that should be 
flushed before cleanup when they participate in a reference cycle? Adding a 
special "__predel__" method as suggested in the linked bug? Weak backrefs for 
file objects that allow a child being destroyed to flush/close its parent 
(recursively) such that the top of the I/O wrapping chain is always 
flushed/closed first? Something else?

The underlying problem is that people don't use with statements or otherwise 
explicitly close their objects, and 99.9% of the time, they get away with it in 
CPython because of the deterministic reference counting for non-cycles and the 
finalizers. I'm not sure it's worth adding new complexity (to the interpreter 
or the I/O hierarchy) to address an issue that can be fixed by closing your 
files properly, which is already recommended practice.

--
nosy: +josh.r

___
Python tracker 

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



[issue22996] Order of _io objects finalization can lose data in reference cycles

2014-12-04 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue22996] Order of _io objects finalization can lose data in reference cycles

2014-12-04 Thread Antoine Pitrou

New submission from Antoine Pitrou:

Spun off from issue #17852, which sticks to interpreter shutdown issue. There 
is a more general issue when e.g. a BufferedWriter can be finalized 
(tp_finalize) before the TextIOWrapper wrapping it if they belong to a 
reference chain, losing unflushed data.

Reproducer attached.

--
components: IO
files: gcio.py
messages: 232138
nosy: pitrou
priority: normal
severity: normal
status: open
title: Order of _io objects finalization can lose data in reference cycles
versions: Python 3.4, Python 3.5
Added file: http://bugs.python.org/file37358/gcio.py

___
Python tracker 

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