Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
ad4b0001
Commit
ad4b0001
authored
Oct 07, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #14783: Backport changes from 3.2.
parent
e4831f6b
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
44 additions
and
24 deletions
+44
-24
Doc/library/functions.rst
Doc/library/functions.rst
+5
-3
Misc/NEWS
Misc/NEWS
+3
-0
Objects/intobject.c
Objects/intobject.c
+13
-8
Objects/longobject.c
Objects/longobject.c
+12
-6
Objects/rangeobject.c
Objects/rangeobject.c
+2
-1
Objects/sliceobject.c
Objects/sliceobject.c
+2
-1
Objects/stringobject.c
Objects/stringobject.c
+1
-1
Objects/unicodeobject.c
Objects/unicodeobject.c
+4
-3
Python/bltinmodule.c
Python/bltinmodule.c
+2
-1
No files found.
Doc/library/functions.rst
View file @
ad4b0001
...
@@ -733,7 +733,8 @@ available. They are listed here in alphabetical order.
...
@@ -733,7 +733,8 @@ available. They are listed here in alphabetical order.
affect the values of local and free variables used by the interpreter.
affect the values of local and free variables used by the interpreter.
.. function:: long([x[, base]])
.. function:: long(x=0)
long(x, base=10)
Convert a string or number to a long integer. If the argument is a string, it
Convert a string or number to a long integer. If the argument is a string, it
must contain a possibly signed number of arbitrary size, possibly embedded in
must contain a possibly signed number of arbitrary size, possibly embedded in
...
@@ -1318,7 +1319,7 @@ available. They are listed here in alphabetical order.
...
@@ -1318,7 +1319,7 @@ available. They are listed here in alphabetical order.
Function decorator syntax added.
Function decorator syntax added.
.. function:: str(
[object]
)
.. function:: str(
object=''
)
Return a string containing a nicely printable representation of an object. For
Return a string containing a nicely printable representation of an object. For
strings, this returns the string itself. The difference with ``repr(object)``
strings, this returns the string itself. The difference with ``repr(object)``
...
@@ -1463,7 +1464,8 @@ available. They are listed here in alphabetical order.
...
@@ -1463,7 +1464,8 @@ available. They are listed here in alphabetical order.
.. versionadded:: 2.0
.. versionadded:: 2.0
.. function:: unicode([object[, encoding [, errors]]])
.. function:: unicode(object='')
unicode(object[, encoding [, errors]])
Return the Unicode string version of *object* using one of the following modes:
Return the Unicode string version of *object* using one of the following modes:
...
...
Misc/NEWS
View file @
ad4b0001
...
@@ -9,6 +9,9 @@ What's New in Python 2.7.4
...
@@ -9,6 +9,9 @@ What's New in Python 2.7.4
Core and Builtins
Core and Builtins
-----------------
-----------------
- Issue #14783: Improve int() and long() docstrings and switch docstrings for
unicode(), slice(), range(), and xrange() to use multi-line signatures.
- Issue #16030: Fix overflow bug in computing the `repr` of an xrange object
- Issue #16030: Fix overflow bug in computing the `repr` of an xrange object
with large start, step or length.
with large start, step or length.
...
...
Objects/intobject.c
View file @
ad4b0001
...
@@ -1334,15 +1334,20 @@ static PyGetSetDef int_getset[] = {
...
@@ -1334,15 +1334,20 @@ static PyGetSetDef int_getset[] = {
};
};
PyDoc_STRVAR
(
int_doc
,
PyDoc_STRVAR
(
int_doc
,
"int(x[, base]) -> integer
\n
\
"int(x=0) -> int or long
\n
\
int(x, base=10) -> int or long
\n
\
\n
\
\n
\
Convert a string or number to an integer, if possible. A floating point
\n
\
Convert a number or string to an integer, or return 0 if no arguments
\n
\
argument will be truncated towards zero (this does not include a string
\n
\
are given. If x is floating point, the conversion truncates towards zero.
\n
\
representation of a floating point number!) When converting a string, use
\n
\
If x is outside the integer range, the function returns a long instead.
\n
\
the optional base. It is an error to supply a base when converting a
\n
\
\n
\
non-string. If base is zero, the proper base is guessed based on the
\n
\
If x is not a number or if base is given, then x must be a string or
\n
\
string content. If the argument is outside the integer range a
\n
\
Unicode object representing an integer literal in the given base. The
\n
\
long object will be returned instead."
);
literal can be preceded by '+' or '-' and be surrounded by whitespace.
\n
\
The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to
\n
\
interpret the base from the string as an integer literal.
\n
\
>>> int('0b100', base=0)
\n
\
4"
);
static
PyNumberMethods
int_as_number
=
{
static
PyNumberMethods
int_as_number
=
{
(
binaryfunc
)
int_add
,
/*nb_add*/
(
binaryfunc
)
int_add
,
/*nb_add*/
...
...
Objects/longobject.c
View file @
ad4b0001
...
@@ -4221,13 +4221,19 @@ static PyGetSetDef long_getset[] = {
...
@@ -4221,13 +4221,19 @@ static PyGetSetDef long_getset[] = {
};
};
PyDoc_STRVAR
(
long_doc
,
PyDoc_STRVAR
(
long_doc
,
"long(x[, base]) -> integer
\n
\
"long(x=0) -> long
\n
\
long(x, base=10) -> long
\n
\
\n
\
\n
\
Convert a string or number to a long integer, if possible. A floating
\n
\
Convert a number or string to a long integer, or return 0L if no arguments
\n
\
point argument will be truncated towards zero (this does not include a
\n
\
are given. If x is floating point, the conversion truncates towards zero.
\n
\
string representation of a floating point number!) When converting a
\n
\
\n
\
string, use the optional base. It is an error to supply a base when
\n
\
If x is not a number or if base is given, then x must be a string or
\n
\
converting a non-string."
);
Unicode object representing an integer literal in the given base. The
\n
\
literal can be preceded by '+' or '-' and be surrounded by whitespace.
\n
\
The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to
\n
\
interpret the base from the string as an integer literal.
\n
\
>>> int('0b100', base=0)
\n
\
4L"
);
static
PyNumberMethods
long_as_number
=
{
static
PyNumberMethods
long_as_number
=
{
(
binaryfunc
)
long_add
,
/*nb_add*/
(
binaryfunc
)
long_add
,
/*nb_add*/
...
...
Objects/rangeobject.c
View file @
ad4b0001
...
@@ -104,7 +104,8 @@ range_new(PyTypeObject *type, PyObject *args, PyObject *kw)
...
@@ -104,7 +104,8 @@ range_new(PyTypeObject *type, PyObject *args, PyObject *kw)
}
}
PyDoc_STRVAR
(
range_doc
,
PyDoc_STRVAR
(
range_doc
,
"xrange([start,] stop[, step]) -> xrange object
\n
\
"xrange(stop) -> xrange object
\n
\
xrange(start, stop[, step]) -> xrange object
\n
\
\n
\
\n
\
Like range(), but instead of returning a list, returns an object that
\n
\
Like range(), but instead of returning a list, returns an object that
\n
\
generates the numbers in the range on demand. For looping, this is
\n
\
generates the numbers in the range on demand. For looping, this is
\n
\
...
...
Objects/sliceobject.c
View file @
ad4b0001
...
@@ -211,7 +211,8 @@ slice_new(PyTypeObject *type, PyObject *args, PyObject *kw)
...
@@ -211,7 +211,8 @@ slice_new(PyTypeObject *type, PyObject *args, PyObject *kw)
}
}
PyDoc_STRVAR
(
slice_doc
,
PyDoc_STRVAR
(
slice_doc
,
"slice([start,] stop[, step])
\n
\
"slice(stop)
\n
\
slice(start, stop[, step])
\n
\
\n
\
\n
\
Create a slice object. This is used for extended slicing (e.g. a[0:10:2])."
);
Create a slice object. This is used for extended slicing (e.g. a[0:10:2])."
);
...
...
Objects/stringobject.c
View file @
ad4b0001
...
@@ -3799,7 +3799,7 @@ PyTypeObject PyBaseString_Type = {
...
@@ -3799,7 +3799,7 @@ PyTypeObject PyBaseString_Type = {
};
};
PyDoc_STRVAR
(
string_doc
,
PyDoc_STRVAR
(
string_doc
,
"str(object) -> string
\n
\
"str(object
=''
) -> string
\n
\
\n
\
\n
\
Return a nice string representation of the object.
\n
\
Return a nice string representation of the object.
\n
\
If the argument is a string, the return value is the same object."
);
If the argument is a string, the return value is the same object."
);
...
...
Objects/unicodeobject.c
View file @
ad4b0001
...
@@ -8759,7 +8759,8 @@ unicode_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
...
@@ -8759,7 +8759,8 @@ unicode_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}
}
PyDoc_STRVAR
(
unicode_doc
,
PyDoc_STRVAR
(
unicode_doc
,
"unicode(string [, encoding[, errors]]) -> object
\n
\
"unicode(object='') -> unicode object
\n
\
unicode(string[, encoding[, errors]]) -> unicode object
\n
\
\n
\
\n
\
Create a new Unicode object from the given encoded string.
\n
\
Create a new Unicode object from the given encoded string.
\n
\
encoding defaults to the current default string encoding.
\n
\
encoding defaults to the current default string encoding.
\n
\
...
...
Python/bltinmodule.c
View file @
ad4b0001
...
@@ -2004,7 +2004,8 @@ builtin_range(PyObject *self, PyObject *args)
...
@@ -2004,7 +2004,8 @@ builtin_range(PyObject *self, PyObject *args)
}
}
PyDoc_STRVAR
(
range_doc
,
PyDoc_STRVAR
(
range_doc
,
"range([start,] stop[, step]) -> list of integers
\n
\
"range(stop) -> list of integers
\n
\
range(start, stop[, step]) -> list of integers
\n
\
\n
\
\n
\
Return a list containing an arithmetic progression of integers.
\n
\
Return a list containing an arithmetic progression of integers.
\n
\
range(i, j) returns [i, i+1, i+2, ..., j-1]; start (!) defaults to 0.
\n
\
range(i, j) returns [i, i+1, i+2, ..., j-1]; start (!) defaults to 0.
\n
\
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment