bug-readline
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Readline history bug


From: A
Subject: Readline history bug
Date: Fri, 31 Jan 2020 20:35:24 +0000

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Friday, 31 January 2020 20:32, A <address@hidden> wrote:

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

Attachment: publickey - auroralanes@protonmail.ch - 0x72D037C6.asc
Description: application/pgp-keys

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]