Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 042fa65

Browse files
committed
Issue #14783: Merge changes from 3.2.
2 parents 3e5dae0 + 83fe2e1 commit 042fa65

6 files changed

Lines changed: 25 additions & 11 deletions

File tree

Doc/library/functions.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,8 @@ are always available. They are listed here in alphabetical order.
12031203

12041204

12051205
.. _func-str:
1206-
.. function:: str([object[, encoding[, errors]]])
1206+
.. function:: str(object='')
1207+
str(object[, encoding[, errors]])
12071208

12081209
Return a string version of an object, using one of the following modes:
12091210

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ What's New in Python 3.3.1?
1212
Core and Builtins
1313
-----------------
1414

15+
- Issue #14783: Improve int() docstring and switch docstrings for str(),
16+
range(), and slice() to use multi-line signatures.
17+
1518
- Issue #15379: Fix passing of non-BMP characters as integers for the charmap
1619
decoder (already working as unicode strings). Patch by Serhiy Storchaka.
1720

Objects/longobject.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4848,13 +4848,20 @@ static PyGetSetDef long_getset[] = {
48484848
};
48494849

48504850
PyDoc_STRVAR(long_doc,
4851-
"int(x[, base]) -> integer\n\
4851+
"int(x=0) -> integer\n\
4852+
int(x, base=10) -> integer\n\
48524853
\n\
4853-
Convert a string or number to an integer, if possible. A floating\n\
4854-
point argument will be truncated towards zero (this does not include a\n\
4855-
string representation of a floating point number!) When converting a\n\
4856-
string, use the optional base. It is an error to supply a base when\n\
4857-
converting a non-string.");
4854+
Convert a number or string to an integer, or return 0 if no arguments\n\
4855+
are given. If x is a number, return x.__int__(). For floating point\n\
4856+
numbers, this truncates towards zero.\n\
4857+
\n\
4858+
If x is not a number or if base is given, then x must be a string,\n\
4859+
bytes, or bytearray instance representing an integer literal in the\n\
4860+
given base. The literal can be preceded by '+' or '-' and be surrounded\n\
4861+
by whitespace. The base defaults to 10. Valid bases are 0 and 2-36.\n\
4862+
Base 0 means to interpret the base from the string as an integer literal.\n\
4863+
>>> int('0b100', base=0)\n\
4864+
4");
48584865

48594866
static PyNumberMethods long_as_number = {
48604867
(binaryfunc)long_add, /*nb_add*/

Objects/rangeobject.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ range_new(PyTypeObject *type, PyObject *args, PyObject *kw)
136136
}
137137

138138
PyDoc_STRVAR(range_doc,
139-
"range([start,] stop[, step]) -> range object\n\
139+
"range(stop) -> range object\n\
140+
range(start, stop[, step]) -> range object\n\
140141
\n\
141142
Returns a virtual sequence of numbers from start to stop by step.");
142143

@@ -969,7 +970,7 @@ rangeiter_reduce(rangeiterobject *r)
969970
{
970971
PyObject *start=NULL, *stop=NULL, *step=NULL;
971972
PyObject *range;
972-
973+
973974
/* create a range object for pickling */
974975
start = PyLong_FromLong(r->start);
975976
if (start == NULL)

Objects/sliceobject.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ slice_new(PyTypeObject *type, PyObject *args, PyObject *kw)
269269
}
270270

271271
PyDoc_STRVAR(slice_doc,
272-
"slice([start,] stop[, step])\n\
272+
"slice(stop)\n\
273+
slice(start, stop[, step])\n\
273274
\n\
274275
Create a slice object. This is used for extended slicing (e.g. a[0:10:2]).");
275276

Objects/unicodeobject.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14074,7 +14074,8 @@ unicode_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
1407414074
}
1407514075

1407614076
PyDoc_STRVAR(unicode_doc,
14077-
"str(object[, encoding[, errors]]) -> str\n\
14077+
"str(object='') -> str\n\
14078+
str(bytes_or_buffer[, encoding[, errors]]) -> str\n\
1407814079
\n\
1407914080
Create a new string object from the given object. If encoding or\n\
1408014081
errors is specified, then the object must expose a data buffer\n\

0 commit comments

Comments
 (0)