Title: PyLong_FromString documentation should state that the string must be null-terminated
Type: Stage:
Components: Documentation Versions:
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Rosuav, docs@python, rfk
Priority: normal Keywords: patch

Created on 2012-06-04 00:32 by rfk, last changed 2014-03-02 15:23 by Rosuav.

File name Uploaded Description Edit
PyLong_FromString-doc.patch rfk, 2012-06-04 00:32 review
Messages (2)
msg162242 - (view) Author: Ryan Kelly (rfk) Date: 2012-06-04 00:32
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.
msg212559 - (view) Author: Chris Angelico (Rosuav) * Date: 2014-03-02 15:23
Patch doesn't apply to current Python trunk (18 months later). Do you know what version you wrote this against? The current wording is different.
Date User Action Args
2014-03-02 15:23:13Rosuavsetnosy: + Rosuav
messages: + msg212559
2012-06-04 00:32:53rfkcreate