Mercurial > hgrepos > Python > libs > ConfigMix
comparison configmix/_speedups.c @ 630:33264c660fca
Exception formatting: more into into some exception error messages
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sun, 16 Jan 2022 09:46:57 +0100 |
| parents | e3a23e9242a0 |
| children | 4499e9b4855d |
comparison
equal
deleted
inserted
replaced
| 629:2426fa273a29 | 630:33264c660fca |
|---|---|
| 61 else { | 61 else { |
| 62 if ((c >= 65) && (c <= 70)) { /* A - F */ | 62 if ((c >= 65) && (c <= 70)) { /* A - F */ |
| 63 r += (c - 55); | 63 r += (c - 55); |
| 64 } | 64 } |
| 65 else { | 65 else { |
| 66 PyErr_SetString(PyExc_ValueError, "invalid base-16 literal"); | 66 PyErr_Format(PyExc_ValueError, "invalid base-16 literal: %c", (int)c); |
| 67 return -1; | 67 return -1; |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 } | 71 } |
| 331 | 331 |
| 332 for (i=1; i<parts_len; i++) { | 332 for (i=1; i<parts_len; i++) { |
| 333 pb = PyList_GetItem(parts, i); /* borrowed */ | 333 pb = PyList_GetItem(parts, i); /* borrowed */ |
| 334 pb_len = PyUnicode_GetLength(pb); | 334 pb_len = PyUnicode_GetLength(pb); |
| 335 if (pb_len < 1) { | 335 if (pb_len < 1) { |
| 336 PyErr_SetString(PyExc_ValueError, "unknown quote syntax string"); | 336 PyErr_Format(PyExc_ValueError, "quote syntax: length too small: %U", pb); |
| 337 goto error; | 337 goto error; |
| 338 } | 338 } |
| 339 c = PyUnicode_ReadChar(pb, 0); | 339 c = PyUnicode_ReadChar(pb, 0); |
| 340 switch (c) { | 340 switch (c) { |
| 341 case 0x55: /* U */ | 341 case 0x55: /* U */ |
| 342 if (pb_len < 9) { | 342 if (pb_len < 9) { |
| 343 PyErr_SetString(PyExc_ValueError, "quote syntax: length too small"); | 343 PyErr_Format(PyExc_ValueError, "quote syntax: length too small: %U", pb); |
| 344 goto error; | 344 goto error; |
| 345 } | 345 } |
| 346 o = _hex2string(pb, 9); | 346 o = _hex2string(pb, 9); |
| 347 if (o == NULL) { | 347 if (o == NULL) { |
| 348 goto error; | 348 goto error; |
| 354 } | 354 } |
| 355 PyTuple_SetItem(res_parts, i*2, o); /* steals */ | 355 PyTuple_SetItem(res_parts, i*2, o); /* steals */ |
| 356 break; | 356 break; |
| 357 case 0x75: /* u */ | 357 case 0x75: /* u */ |
| 358 if (pb_len < 5) { | 358 if (pb_len < 5) { |
| 359 PyErr_SetString(PyExc_ValueError, "quote syntax: length too small"); | 359 PyErr_Format(PyExc_ValueError, "quote syntax: length too small: %U", pb); |
| 360 goto error; | 360 goto error; |
| 361 } | 361 } |
| 362 o = _hex2string(pb, 5); | 362 o = _hex2string(pb, 5); |
| 363 if (o == NULL) { | 363 if (o == NULL) { |
| 364 goto error; | 364 goto error; |
| 370 } | 370 } |
| 371 PyTuple_SetItem(res_parts, i*2, o); /* steals */ | 371 PyTuple_SetItem(res_parts, i*2, o); /* steals */ |
| 372 break; | 372 break; |
| 373 case 0x78: /* x */ | 373 case 0x78: /* x */ |
| 374 if (pb_len < 3) { | 374 if (pb_len < 3) { |
| 375 PyErr_SetString(PyExc_ValueError, "quote syntax: length too small"); | 375 PyErr_Format(PyExc_ValueError, "quote syntax: length too small: %U", pb); |
| 376 goto error; | 376 goto error; |
| 377 } | 377 } |
| 378 o = _hex2string(pb, 3); | 378 o = _hex2string(pb, 3); |
| 379 if (o == NULL) { | 379 if (o == NULL) { |
| 380 goto error; | 380 goto error; |
| 386 } | 386 } |
| 387 PyTuple_SetItem(res_parts, i*2, o); /* steals */ | 387 PyTuple_SetItem(res_parts, i*2, o); /* steals */ |
| 388 break; | 388 break; |
| 389 | 389 |
| 390 default: | 390 default: |
| 391 PyErr_SetString(PyExc_ValueError, "unknown quote syntax string"); | 391 PyErr_Format(PyExc_ValueError, "quote syntax: length too small: %U", pb); |
| 392 goto error; | 392 goto error; |
| 393 } | 393 } |
| 394 } | 394 } |
| 395 | 395 |
| 396 res = PyUnicode_Join(sstate->EMPTY_STR, res_parts); | 396 res = PyUnicode_Join(sstate->EMPTY_STR, res_parts); |
