cpython/Modules
Neil Schemenauer 0a1ff24acf bpo-17852: Maintain a list of BufferedWriter objects. Flush them on exit. (#3372)
* Maintain a list of BufferedWriter objects.  Flush them on exit.

In Python 3, the buffer and the underlying file object are separate
and so the order in which objects are finalized matters.  This is
unlike Python 2 where the file and buffer were a single object and
finalization was done for both at the same time.  In Python 3, if
the file is finalized and closed before the buffer then the data in
the buffer is lost.

This change adds a doubly linked list of open file buffers.  An atexit
hook ensures they are flushed before proceeding with interpreter
shutdown.  This is addition does not remove the need to properly close
files as there are other reasons why buffered data could get lost during
finalization.

Initial patch by Armin Rigo.

* Use weakref.WeakSet instead of WeakKeyDictionary.

* Simplify buffered double-linked list types.

* In _flush_all_writers(), suppress errors from flush().

* Remove NEWS entry, use blurb.

* Take more care when flushing file buffers from atexit.

The previous implementation was not careful enough to avoid
causing issues in multi-threaded cases.  Check for buf->ok
and buf->finalizing before actually doing the flush.  Also,
increase the refcnt to ensure the object does not disappear.
2017-09-22 10:17:30 -07:00
..
_blake2 bpo-31370: Remove support for threads-less builds (#3385) 2017-09-07 18:56:24 +02:00
_ctypes bpo-31490: Fix an assertion failure in ctypes in case an _anonymous_ attr is defined only outside _fields_. (#3615) 2017-09-17 13:45:38 +03:00
_decimal bpo-31406: Fix crash due to lack of type checking in subclassing. (#3477) 2017-09-10 18:08:04 +02:00
_io bpo-17852: Maintain a list of BufferedWriter objects. Flush them on exit. (#3372) 2017-09-22 10:17:30 -07:00
_multiprocessing bpo-30022: Get rid of using EnvironmentError and IOError (except test… (#1051) 2017-04-16 10:46:38 +03:00
_sha3 bpo-31370: Remove support for threads-less builds (#3385) 2017-09-07 18:56:24 +02:00
_sqlite closes bpo-31525: require sqlite3_prepare_v2 (#3666) 2017-09-20 07:36:18 -07:00
_xxtestfuzz Avoid UB in test selection macro. (#3407) 2017-09-06 18:00:47 -07:00
cjkcodecs bpo-31275: Small refactoring to silence a fall-through warning. (#3206) 2017-08-25 18:31:22 +02:00
clinic bpo-31428: Prevent raising a SystemError in case the memo arg of ElementTree.Element.__deepcopy__() isn't a dictionary. (#3512) 2017-09-12 17:39:15 +03:00
expat bpo-31462: Remove trailing whitespaces. (#3564) 2017-09-14 09:38:36 +03:00
_asynciomodule.c bpo-31185: Fixed miscellaneous errors in asyncio speedup module. (#3076) 2017-09-03 08:10:14 +03:00
_bisectmodule.c Issue #28792: Remove aliases from _bisect 2016-11-24 23:31:59 +01:00
_bz2module.c bpo-31370: Remove support for threads-less builds (#3385) 2017-09-07 18:56:24 +02:00
_codecsmodule.c bpo-24037: Add Argument Clinic converter bool(accept={int}). (#485) 2017-03-12 10:10:47 +02:00
_collectionsmodule.c bpo-27541: Reprs of subclasses of some classes now contain actual type name. (#3631) 2017-09-21 14:24:13 +03:00
_cryptmodule.c Issue #27332: Fixed the type of the first argument of module-level functions 2016-07-07 17:35:15 +03:00
_csv.c Use NULL rather than 0. (#778) 2017-03-23 17:53:47 +02:00
_curses_panel.c Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever 2017-01-23 09:47:21 +02:00
_cursesmodule.c [security] bpo-13617: Reject embedded null characters in wchar* strings. (#2302) 2017-06-28 08:30:06 +03:00
_datetimemodule.c bpo-31293: Fix crashes in truediv and mul of a timedelta by a float with a bad as_integer_ratio() method. (#3227) 2017-09-19 15:58:11 +03:00
_dbmmodule.c bpo-30022: Get rid of using EnvironmentError and IOError (except test… (#1051) 2017-04-16 10:46:38 +03:00
_elementtree.c bpo-31499, xml.etree: Fix xmlparser_gc_clear() crash (#3641) 2017-09-18 05:29:37 -07:00
_functoolsmodule.c bpo-31497: Add private helper _PyType_Name(). (#3630) 2017-09-17 21:11:04 +03:00
_gdbmmodule.c bpo-30022: Get rid of using EnvironmentError and IOError (except test… (#1051) 2017-04-16 10:46:38 +03:00
_hashopenssl.c bpo-31370: Remove support for threads-less builds (#3385) 2017-09-07 18:56:24 +02:00
_heapqmodule.c Issue #15984: Merge PyUnicode doc from 3.5 2016-04-15 02:27:11 +00:00
_json.c bpo-30860: Move windows.h include out of internal/*.h. (#3458) 2017-09-11 18:30:43 -07:00
_localemodule.c [security] bpo-13617: Reject embedded null characters in wchar* strings. (#2302) 2017-06-28 08:30:06 +03:00
_lsprof.c Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever 2017-01-23 09:47:21 +02:00
_lzmamodule.c bpo-31370: Remove support for threads-less builds (#3385) 2017-09-07 18:56:24 +02:00
_math.c Issue #28256: Cleanup _math.c 2016-10-18 16:29:27 +02:00
_math.h Issue #28256: Cleanup _math.c 2016-10-18 16:29:27 +02:00
_opcode.c Issue #27332: Fixed the type of the first argument of module-level functions 2016-07-07 17:35:15 +03:00
_operator.c bpo-30592: Fixed error messages for some builtins. (#1996) 2017-06-08 14:41:19 +03:00
_pickle.c bpo-28411: Support other mappings in PyInterpreterState.modules. (#3593) 2017-09-15 16:35:20 -06:00
_posixsubprocess.c bpo-16500: Don't use string constants for os.register_at_fork() behavior (#1834) 2017-05-29 10:03:41 -07:00
_randommodule.c bpo-30592: Fixed error messages for some builtins. (#1996) 2017-06-08 14:41:19 +03:00
_scproxy.c Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever 2017-01-23 09:47:21 +02:00
_sre.c bpo-30285: Optimize case-insensitive matching and searching (#1482) 2017-05-09 23:37:14 +03:00
_ssl.c bpo-31431: SSLContext.check_hostname auto-sets CERT_REQUIRED (#3531) 2017-09-15 20:29:57 +02:00
_ssl_data.h Issue #23248: Update ssl error codes from latest OpenSSL git master. 2015-01-18 17:39:32 +01:00
_stat.c Issue #21741: Add st_file_attributes to os.stat_result on Windows. 2014-06-19 09:46:37 -05:00
_struct.c bpo-30246: fix several error messages which only mention bytes in struct (#1421) 2017-09-14 10:33:26 +08:00
_testbuffer.c Expand the PySlice_GetIndicesEx macro. (#1023) 2017-04-08 09:53:51 +03:00
_testcapimodule.c bpo-31370: Remove support for threads-less builds (#3385) 2017-09-07 18:56:24 +02:00
_testimportmultiple.c
_testmultiphase.c Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever 2017-01-23 09:47:21 +02:00
_threadmodule.c bpo-30860: Consolidate stateful runtime globals. (#3397) 2017-09-07 23:51:28 -06:00
_tkinter.c bpo-31370: Remove support for threads-less builds (#3385) 2017-09-07 18:56:24 +02:00
_tracemalloc.c bpo-31338 (#3374) 2017-09-14 18:13:16 -07:00
_weakref.c Issue #28427: old keys should not remove new values from 2016-12-27 14:19:20 +01:00
_winapi.c bpo-31471: Fix assertion failure in subprocess.Popen() on Windows, in case env has a bad keys() method. (#3580) 2017-09-14 22:30:27 +03:00
addrinfo.h replace PY_LONG_LONG with long long 2016-09-06 10:46:49 -07:00
arraymodule.c bpo-27541: Reprs of subclasses of some classes now contain actual type name. (#3631) 2017-09-21 14:24:13 +03:00
atexitmodule.c bpo-28994: Fixed errors handling in atexit._run_exitfuncs(). (#2034) 2017-06-12 08:25:04 +03:00
audioop.c bpo-28261: Fixed err msgs where PyArg_ParseTuple is used to parse normal tuples. (#3119) 2017-08-20 18:35:36 +03:00
binascii.c bpo-9566: Fix some Windows x64 compiler warnings (#2492) 2017-07-26 15:17:57 -07:00
cmathmodule.c Issue 23229: add cmath.inf, cmath.nan, cmath.infj and cmath.nanj. 2016-08-29 13:56:58 +01:00
config.c.in PEP 489: Multi-phase extension module initialization 2015-05-23 22:24:10 +10:00
errnomodule.c
faulthandler.c bpo-31370: Remove support for threads-less builds (#3385) 2017-09-07 18:56:24 +02:00
fcntlmodule.c bpo-30022: Get rid of using EnvironmentError and IOError (except test… (#1051) 2017-04-16 10:46:38 +03:00
fpectlmodule.c remove IRIX support (closes bpo-31341) (#3310) 2017-09-04 16:36:05 -07:00
fpetestmodule.c Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever 2017-01-23 09:47:21 +02:00
gc_weakref.txt
gcmodule.c bpo-30860: Consolidate stateful runtime globals. (#3397) 2017-09-07 23:51:28 -06:00
getaddrinfo.c Issue #26505: merge from 3.5 2016-03-07 14:52:46 -05:00
getbuildinfo.c bpo-27593: Get SCM build info from git instead of hg. (#446) 2017-03-04 00:19:55 -05:00
getnameinfo.c
getpath.c bpo-31532: Fix memory corruption due to allocator mix (#3679) 2017-09-20 23:08:20 -07:00
grpmodule.c [security] bpo-13617: Reject embedded null characters in wchar* strings. (#2302) 2017-06-28 08:30:06 +03:00
hashlib.h bpo-31370: Remove support for threads-less builds (#3385) 2017-09-07 18:56:24 +02:00
hashtable.c Issue #28126: Replace Py_MEMCPY with memcpy(). Visual Studio can properly optimize memcpy(). 2016-09-13 20:22:02 +02:00
hashtable.h Issue #28126: Replace Py_MEMCPY with memcpy(). Visual Studio can properly optimize memcpy(). 2016-09-13 20:22:02 +02:00
itertoolsmodule.c bpo-27541: Reprs of subclasses of some classes now contain actual type name. (#3631) 2017-09-21 14:24:13 +03:00
ld_so_aix.in Issue #10656: Fix out-of-tree building on AIX 2016-11-20 07:56:37 +00:00
main.c bpo-30860: Consolidate stateful runtime globals. (#3397) 2017-09-07 23:51:28 -06:00
makesetup bpo-20210: Support the *disabled* marker in Setup files (GH-132) 2017-05-27 18:25:03 +02:00
makexp_aix
mathmodule.c bpo-31338 (#3374) 2017-09-14 18:13:16 -07:00
md5module.c Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever 2017-01-23 09:47:21 +02:00
mmapmodule.c Expand the PySlice_GetIndicesEx macro. (#1023) 2017-04-08 09:53:51 +03:00
nismodule.c [security] bpo-13617: Reject embedded null characters in wchar* strings. (#2302) 2017-06-28 08:30:06 +03:00
ossaudiodev.c bpo-30022: Get rid of using EnvironmentError and IOError (except test… (#1051) 2017-04-16 10:46:38 +03:00
overlapped.c bpo-28261: Fixed err msgs where PyArg_ParseTuple is used to parse normal tuples. (#3119) 2017-08-20 18:35:36 +03:00
parsermodule.c bpo-30070: Fixed leaks and crashes in errors handling in the parser module. (#1131) 2017-04-19 21:09:21 +03:00
posixmodule.c bpo-31370: Remove support for threads-less builds (#3385) 2017-09-07 18:56:24 +02:00
posixmodule.h
pwdmodule.c [security] bpo-13617: Reject embedded null characters in wchar* strings. (#2302) 2017-06-28 08:30:06 +03:00
pyexpat.c bpo-28411: Support other mappings in PyInterpreterState.modules. (#3593) 2017-09-15 16:35:20 -06:00
readline.c bpo-31370: Remove support for threads-less builds (#3385) 2017-09-07 18:56:24 +02:00
README Issue #18093: Factor out the programs that embed the runtime 2014-07-25 21:52:14 +10:00
resource.c bpo-20185: Convert the resource moduel to Argument Clinic. (#545) 2017-03-12 13:08:30 +02:00
rotatingtree.c
rotatingtree.h
selectmodule.c bpo-30061: Check if PyObject_Size()/PySequence_Size()/PyMapping_Size() (#1096) 2017-04-19 20:03:52 +03:00
Setup.dist bpo-31370: Remove support for threads-less builds (#3385) 2017-09-07 18:56:24 +02:00
sha1module.c Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever 2017-01-23 09:47:21 +02:00
sha256module.c Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever 2017-01-23 09:47:21 +02:00
sha512module.c Removed redundant Argument Clinic directives. 2017-02-04 11:53:22 +02:00
signalmodule.c bpo-31370: Remove support for threads-less builds (#3385) 2017-09-07 18:56:24 +02:00
socketmodule.c Remove a null statement that was necessary for --without-threads (#3478) 2017-09-11 12:37:10 +02:00
socketmodule.h bpo-31462: Remove trailing whitespaces. (#3564) 2017-09-14 09:38:36 +03:00
spwdmodule.c [security] bpo-13617: Reject embedded null characters in wchar* strings. (#2302) 2017-06-28 08:30:06 +03:00
sre.h Issue #28765: _sre.compile() now checks the type of groupindex and indexgroup 2016-11-22 23:04:39 +01:00
sre_constants.h bpo-30215: Make re.compile() locale agnostic. (#1361) 2017-05-05 08:53:40 +03:00
sre_lib.h bpo-30215: Make re.compile() locale agnostic. (#1361) 2017-05-05 08:53:40 +03:00
symtablemodule.c Issue #20186: Converted the symtable module to Argument Clinic. 2017-02-04 12:13:20 +02:00
syslogmodule.c Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever 2017-01-23 09:47:21 +02:00
termios.c Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever 2017-01-23 09:47:21 +02:00
testcapi_long.h
timemodule.c bpo-28261: Fixed err msgs where PyArg_ParseTuple is used to parse normal tuples. (#3119) 2017-08-20 18:35:36 +03:00
tkappinit.c Issue #4350: Removed a number of out-of-dated and non-working for a long time 2014-07-23 22:33:50 +03:00
tkinter.h Issue #16840. Turn off bignum support in tkinter with with Tcl earlier than 8.5.8 2015-04-22 10:59:32 +03:00
unicodedata.c bpo-30736: upgrade to Unicode 10.0 (#2344) 2017-06-22 22:31:08 -07:00
unicodedata_db.h bpo-30736: upgrade to Unicode 10.0 (#2344) 2017-06-22 22:31:08 -07:00
unicodename_db.h bpo-30736: upgrade to Unicode 10.0 (#2344) 2017-06-22 22:31:08 -07:00
winreparse.h Issue #17599: Use unique _Py_REPARSE_DATA_BUFFER etc names to avoid conflict 2016-08-04 02:38:59 +00:00
xxlimited.c merge 3.5 (#29398) 2017-01-31 23:31:10 -08:00
xxmodule.c bpo-31443: Formulate the type slot initialization rules in terms of C99. (#3688) 2017-09-22 17:44:58 +02:00
xxsubtype.c PEP 489: Multi-phase extension module initialization 2015-05-23 22:24:10 +10:00
zipimport.c bpo-30860: Consolidate stateful runtime globals. (#3397) 2017-09-07 23:51:28 -06:00
zlibmodule.c bpo-31370: Remove support for threads-less builds (#3385) 2017-09-07 18:56:24 +02:00

Source files for standard library extension modules,
and former extension modules that are now builtin modules.