diff --git a/Python/codecs.c b/Python/codecs.c index 9302a3d8707..ec0daf380bf 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -822,7 +822,7 @@ void _PyCodecRegistry_Init(void) _PyCodec_ErrorRegistry = PyDict_New(); if (_PyCodec_ErrorRegistry) { - for (i = 0; i < 5; ++i) { + for (i = 0; i < sizeof(methods)/sizeof(methods[0]); ++i) { PyObject *func = PyCFunction_New(&methods[i].def, NULL); int res; if (!func)