[issue9058] PyUnicodeDecodeError_Create asserts that various arguments are less than INT_MAX

Dave Malcolm report at bugs.python.org
Tue Jun 22 21:06:11 CEST 2010


Dave Malcolm <dmalcolm at redhat.com> added the comment:

>>> Actually, you should be able to just remove the asserts.

Aha, thanks! 

Yes: #define PY_SSIZE_T_CLEAN is defined at the top of Objects/exceptions.c, so yes, Py_VaBuildValue is redirected to _Py_VaBuildValue_SizeT, so that 
  PyEval_CallFunction
calls:
  Py_VaBuildValue(format, vargs)
which is preprocessed to:
  _Py_VaBuildValue_SizeT
which calls:
  return va_build_value(format, va, FLAG_SIZE_T);
which means that "s#" is processed with flags==FLAG_SIZE_T, and thus as "Py_ssize_t" within do_mkvalue:
				if (flags & FLAG_SIZE_T)
					n = va_arg(*p_va, Py_ssize_t);
				else
					n = va_arg(*p_va, int);

So, yes, it does look like the three assert lines can simply be removed.

----------
Added file: http://bugs.python.org/file17747/remove-PyUnicodeDecodeError_Create-assertions-issue9058-v2.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9058>
_______________________________________


More information about the Python-bugs-list mailing list