Patchwork [3,of,6] phases: make sure an exception should be set on error return

login
register
mail settings
Submitter Yuya Nishihara
Date July 18, 2020, 10:12 a.m.
Message ID <d2bef0f97e82641bb671.1595067179@mimosa>
Download mbox | patch
Permalink /patch/46799/
State Accepted
Headers show

Comments

Yuya Nishihara - July 18, 2020, 10:12 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1595064086 -32400
#      Sat Jul 18 18:21:26 2020 +0900
# Node ID d2bef0f97e82641bb6719128fbd0380b08ac539c
# Parent  fb15ffcb12fae7e7c73dfbbc271874f0f3418193
phases: make sure an exception should be set on error return

This should never happen, but the code looks wrong without PyErr_Set*() call.

Patch

diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -862,6 +862,10 @@  static PyObject *compute_phases_map_sets
 			pyphase = phasesets[3];
 			break;
 		default:
+			/* this should never happen since the phase number is
+			 * specified by this function. */
+			PyErr_SetString(PyExc_SystemError,
+			                "bad phase number in internal list");
 			goto release;
 		}
 		pyrev = PyInt_FromLong(rev);