2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-30 22:05:46 +00:00

Python 3.12 backtraces use '~' in addition to '^' when underlining.

GitHub issue #374
This commit is contained in:
Todd C. Miller
2024-05-02 20:02:43 -06:00
parent 2e6c90cdef
commit 89918caf5a

View File

@@ -27,19 +27,19 @@ struct TestData data;
/* /*
* Starting with Python 3.11, backtraces may contain a line with * Starting with Python 3.11, backtraces may contain a line with
* '^' characters to bring attention to the important part of the * '~' and '^' characters to bring attention to the important part
* line. * of the line.
*/ */
static void static void
remove_underline(char *output) remove_underline(char *output)
{ {
char *cp, *ep; char *cp, *ep;
// Remove lines that only consist of '^' and white space. // Remove lines that only consist of '~', '^' and white space.
cp = output; cp = output;
ep = output + strlen(output); ep = output + strlen(output);
for (;;) { for (;;) {
size_t len = strspn(cp, "^ \t"); size_t len = strspn(cp, "~^ \t");
if (len > 0 && cp[len] == '\n') { if (len > 0 && cp[len] == '\n') {
/* Prune out lines that are "underlining". */ /* Prune out lines that are "underlining". */
memmove(cp, cp + len + 1, (size_t)(ep - cp)); memmove(cp, cp + len + 1, (size_t)(ep - cp));