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

Skip to content

Commit 7d1e880

Browse files
committed
Merged revisions 73656,73658,73663,73666 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k ........ r73656 | mark.dickinson | 2009-06-29 00:08:40 +0200 (Mo, 29 Jun 2009) | 1 line Fix description of range_length_obj ........ r73658 | raymond.hettinger | 2009-06-29 00:30:13 +0200 (Mo, 29 Jun 2009) | 1 line Small doc fix-ups to floatingpoint.rst. More are forthcoming. ........ r73663 | raymond.hettinger | 2009-06-29 01:21:38 +0200 (Mo, 29 Jun 2009) | 1 line Clean-up floating point tutorial. ........ r73666 | alexandre.vassalotti | 2009-06-29 03:13:41 +0200 (Mo, 29 Jun 2009) | 2 lines Make b64encode raises properly a TypeError when altchars is not bytes. ........
1 parent 98e472d commit 7d1e880

3 files changed

Lines changed: 10 additions & 11 deletions

File tree

Doc/tutorial/floatingpoint.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ values share the same approximation, any one of them could be displayed
8282
while still preserving the invariant ``eval(repr(x)) == x``.
8383

8484
Historically, the Python prompt and built-in :func:`repr` function would chose
85-
the one with 17 significant digits, ``0.10000000000000001``, Starting with
85+
the one with 17 significant digits, ``0.10000000000000001``. Starting with
8686
Python 3.1, Python (on most systems) is now able to choose the shortest of
8787
these and simply display ``0.1``.
8888

@@ -123,9 +123,9 @@ Also, since the 0.1 cannot get any closer to the exact value of 1/10 and
123123

124124
Though the numbers cannot be made closer to their intended exact values,
125125
the :func:`round` function can be useful for post-rounding so that results
126-
have inexact values that are comparable to one another::
126+
with inexact values become comparable to one another::
127127

128-
>>> round(.1 + .1 + .1, 1) == round(.3, 1)
128+
>>> round(.1 + .1 + .1, 10) == round(.3, 10)
129129
True
130130

131131
Binary floating-point arithmetic holds many surprises like this. The problem
@@ -137,7 +137,7 @@ As that says near the end, "there are no easy answers." Still, don't be unduly
137137
wary of floating-point! The errors in Python float operations are inherited
138138
from the floating-point hardware, and on most machines are on the order of no
139139
more than 1 part in 2\*\*53 per operation. That's more than adequate for most
140-
tasks, but you do need to keep in mind that it's not decimal arithmetic, and
140+
tasks, but you do need to keep in mind that it's not decimal arithmetic and
141141
that every float operation can suffer a new rounding error.
142142

143143
While pathological cases do exist, for most casual use of floating-point
@@ -165,7 +165,7 @@ fraction::
165165

166166
>>> x = 3.14159
167167
>>> x.as_integer_ratio()
168-
(3537115888337719L, 1125899906842624L)
168+
(3537115888337719, 1125899906842624)
169169

170170
Since the ratio is exact, it can be used to losslessly recreate the
171171
original value::

Lib/base64.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ def b64encode(s, altchars=None):
5858
encoded = binascii.b2a_base64(s)[:-1]
5959
if altchars is not None:
6060
if not isinstance(altchars, bytes_types):
61-
altchars = TypeError("expected bytes, not %s"
62-
% altchars.__class__.__name__)
61+
raise TypeError("expected bytes, not %s"
62+
% altchars.__class__.__name__)
6363
assert len(altchars) == 2, repr(altchars)
6464
return _translate(encoded, {'+': altchars[0:1], '/': altchars[1:2]})
6565
return encoded

Objects/rangeobject.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,9 @@ range_dealloc(rangeobject *r)
126126
PyObject_Del(r);
127127
}
128128

129-
/* Return number of items in range (lo, hi, step), when arguments are PyLong
130-
* objects. Return a value < 0 if & only if the true value is too large to
131-
* fit in a signed long. Arguments MUST return 1 with PyLong_Check(). Return
132-
* -1 when there is an error.
129+
/* Return number of items in range (lo, hi, step) as a PyLong object,
130+
* when arguments are PyLong objects. Arguments MUST return 1 with
131+
* PyLong_Check(). Return NULL when there is an error.
133132
*/
134133
static PyObject*
135134
range_length_obj(rangeobject *r)

0 commit comments

Comments
 (0)