The readline package doesn't return the errno for some errors in write_history, append_history, and history_truncate_file. This caused an error in the CPython interpreter(at exit time) when the .python_history file was not writable.
In particular these calls return -1 when the internal`histfile_restore`call fails because`rename`fails. It's fine for`histfile_restore`to return the result from`rename`, but this should be checked for failure (e.g. -1) and handled appropriately by the caller in`history_do_write`and`history_truncate_file`. For example, in`history_do_write`they do the following: if (rv == 0 && histname && tempname) rv = histfile_restore (tempname, histname); if (rv != 0) { if (tempname) unlink (tempname); history_lines_written_to_file = 0; } This needs a simple fix to update the value of`rv`when`histfile_restore`fails: if (rv == 0 && histname && tempname) rv = histfile_restore (tempname, histname); if (rv != 0) { rv = errno; if (tempname) unlink(tempname); history_lines_written_to_file = 0; } Code snippet taken fromĀ https://github.com/python/cpython/pull/18299#issuecomment-580883515
publickey - auroralanes@protonmail.ch - 0x72D037C6.asc
Description: application/pgp-keys
signature.asc
Description: OpenPGP digital signature