@@ -48,6 +48,42 @@ The return value (*rv*) for these functions should be interpreted as follows:
48
48
49
49
The following functions provide locale-independent string to number conversions.
50
50
51
+ .. c:function:: unsigned long PyOS_strtoul(const char *str, char **ptr, int base)
52
+
53
+ Convert the initial part of the string in ``str `` to an :c:expr: `unsigned
54
+ long ` value according to the given ``base ``, which must be between ``2 `` and
55
+ ``36 `` inclusive, or be the special value ``0 ``.
56
+
57
+ Leading white space and case of characters are ignored. If ``base `` is zero
58
+ it looks for a leading ``0b ``, ``0o `` or ``0x `` to tell which base. If
59
+ these are absent it defaults to ``10 ``. Base must be 0 or between 2 and 36
60
+ (inclusive). If ``ptr`` is non-``NULL`` it will contain a pointer to the
61
+ end of the scan.
62
+
63
+ If the converted value falls out of range of corresponding return type,
64
+ range error occurs (:c:data: `errno ` is set to :c:macro: `!ERANGE `) and
65
+ :c:macro:`!ULONG_MAX` is returned. If no conversion can be performed, ``0``
66
+ is returned.
67
+
68
+ See also the Unix man page :manpage:`strtoul(3)`.
69
+
70
+ .. versionadded:: 3.2
71
+
72
+
73
+ .. c:function:: long PyOS_strtol(const char *str, char **ptr, int base)
74
+
75
+ Convert the initial part of the string in ``str `` to an :c:expr: `long ` value
76
+ according to the given ``base ``, which must be between ``2 `` and ``36 ``
77
+ inclusive, or be the special value ``0 ``.
78
+
79
+ Same as :c:func: `PyOS_strtoul `, but return a :c:expr: `long ` value instead
80
+ and :c:macro: `LONG_MAX ` on overflows.
81
+
82
+ See also the Unix man page :manpage: `strtol(3)`.
83
+
84
+ .. versionadded :: 3.2
85
+
86
+
51
87
.. c :function :: double PyOS_string_to_double (const char *s, char **endptr, PyObject *overflow_exception)
52
88
53
89
Convert a string ``s `` to a :c:expr: `double `, raising a Python
0 commit comments