New submission from Ryan Kelly <r...@rfk.id.au>:

PyLong_FromString will raise a ValueError if the given string doesn't contain a 
null byte after the digits.  For example, this will result in a ValueError

   char *pend;
   PyLong_FromString("1234 extra", &pend, 10)

While this will successfully read the number and set the pointer to the extra 
data:

   char *pend;
   PyLong_FromString("1234\0extra", &pend, 10)

The requirement for a null-terminated string of digits is not clear from the 
docs.  Suggested re-wording attached.

----------
assignee: docs@python
components: Documentation
files: PyLong_FromString-doc.patch
keywords: patch
messages: 162242
nosy: docs@python, rfk
priority: normal
severity: normal
status: open
title: PyLong_FromString documentation should state that the string must be 
null-terminated
Added file: http://bugs.python.org/file25812/PyLong_FromString-doc.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue14995>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to