# HG changeset patch # User Franz Glasner # Date 1642322817 -3600 # Node ID 33264c660fca7ba8e39ce32e142f6168fbba9d70 # Parent 2426fa273a2950ad397035b0d8e5af1a0598da74 Exception formatting: more into into some exception error messages diff -r 2426fa273a29 -r 33264c660fca configmix/_speedups.c --- a/configmix/_speedups.c Fri Jan 14 11:59:48 2022 +0100 +++ b/configmix/_speedups.c Sun Jan 16 09:46:57 2022 +0100 @@ -63,7 +63,7 @@ r += (c - 55); } else { - PyErr_SetString(PyExc_ValueError, "invalid base-16 literal"); + PyErr_Format(PyExc_ValueError, "invalid base-16 literal: %c", (int)c); return -1; } } @@ -333,14 +333,14 @@ pb = PyList_GetItem(parts, i); /* borrowed */ pb_len = PyUnicode_GetLength(pb); if (pb_len < 1) { - PyErr_SetString(PyExc_ValueError, "unknown quote syntax string"); + PyErr_Format(PyExc_ValueError, "quote syntax: length too small: %U", pb); goto error; } c = PyUnicode_ReadChar(pb, 0); switch (c) { case 0x55: /* U */ if (pb_len < 9) { - PyErr_SetString(PyExc_ValueError, "quote syntax: length too small"); + PyErr_Format(PyExc_ValueError, "quote syntax: length too small: %U", pb); goto error; } o = _hex2string(pb, 9); @@ -356,7 +356,7 @@ break; case 0x75: /* u */ if (pb_len < 5) { - PyErr_SetString(PyExc_ValueError, "quote syntax: length too small"); + PyErr_Format(PyExc_ValueError, "quote syntax: length too small: %U", pb); goto error; } o = _hex2string(pb, 5); @@ -372,7 +372,7 @@ break; case 0x78: /* x */ if (pb_len < 3) { - PyErr_SetString(PyExc_ValueError, "quote syntax: length too small"); + PyErr_Format(PyExc_ValueError, "quote syntax: length too small: %U", pb); goto error; } o = _hex2string(pb, 3); @@ -388,7 +388,7 @@ break; default: - PyErr_SetString(PyExc_ValueError, "unknown quote syntax string"); + PyErr_Format(PyExc_ValueError, "quote syntax: length too small: %U", pb); goto error; } }