MCPcopy Index your code
hub / github.com/RustPython/RustPython / unicode_call_errorhandler

Function unicode_call_errorhandler

Lib/_pycodecs.py:1367–1395  ·  view source on GitHub ↗
(
    errors, encoding, reason, input, startinpos, endinpos, decode=True
)

Source from the content-addressed store, hash-verified

1365
1366
1367def unicode_call_errorhandler(
1368 errors, encoding, reason, input, startinpos, endinpos, decode=True
1369):
1370 errorHandler = lookup_error(errors)
1371 if decode:
1372 exceptionObject = UnicodeDecodeError(
1373 encoding, input, startinpos, endinpos, reason
1374 )
1375 else:
1376 exceptionObject = UnicodeEncodeError(
1377 encoding, input, startinpos, endinpos, reason
1378 )
1379 res = errorHandler(exceptionObject)
1380 if (
1381 isinstance(res, tuple)
1382 and isinstance(res[0], (str, bytes))
1383 and isinstance(res[1], int)
1384 ):
1385 newpos = res[1]
1386 if newpos < 0:
1387 newpos = len(input) + newpos
1388 if newpos < 0 or newpos > len(input):
1389 raise IndexError("position %d from error handler out of bounds" % newpos)
1390 return res[0], newpos
1391 else:
1392 raise TypeError(
1393 "encoding error handler must return (unicode, int) tuple, not %s"
1394 % repr(res)
1395 )
1396
1397
1398# /* --- Latin-1 Codec ------------------------------------------------------ */

Callers 12

PyUnicode_EncodeUTF32Function · 0.85
PyUnicode_DecodeUTF7Function · 0.85
PyUnicode_DecodeASCIIFunction · 0.85
PyUnicode_EncodeUTF16Function · 0.85
unicode_encode_ucs1Function · 0.85
hexescapeFunction · 0.85
PyUnicode_EncodeCharmapFunction · 0.85
PyUnicode_DecodeCharmapFunction · 0.85

Calls 4

lookup_errorFunction · 0.85
isinstanceFunction · 0.85
lenFunction · 0.85
reprFunction · 0.85

Tested by

no test coverage detected