Skip to content

Commit e4ca815

Browse files
committed
Merged revisions 62805,62811,62841-62842,62848-62849,62853-62854 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r62805 | christian.heimes | 2008-05-07 01:59:53 +0200 (Wed, 07 May 2008) | 1 line Re-added getbuildinfo.c solution item ........ r62811 | benjamin.peterson | 2008-05-07 04:23:43 +0200 (Wed, 07 May 2008) | 2 lines update .bzrignore ........ r62841 | christian.heimes | 2008-05-08 00:54:17 +0200 (Thu, 08 May 2008) | 1 line Replace more float hacks with correct math functions ........ r62842 | benjamin.peterson | 2008-05-08 01:11:54 +0200 (Thu, 08 May 2008) | 2 lines Practice EAFP, and revert 62787 ........ r62848 | raymond.hettinger | 2008-05-08 06:35:20 +0200 (Thu, 08 May 2008) | 1 line Frozensets do not benefit from autoconversion. ........ r62849 | raymond.hettinger | 2008-05-08 06:36:12 +0200 (Thu, 08 May 2008) | 1 line The __all__ variable forgot to expose the gcd() function. ........ r62853 | raymond.hettinger | 2008-05-08 09:23:30 +0200 (Thu, 08 May 2008) | 1 line Fix-up the enumerate type example and move it to the end. ........ r62854 | ronald.oussoren | 2008-05-08 12:34:39 +0200 (Thu, 08 May 2008) | 3 lines Fix for issue 1770190: platform.mac_ver() now returns the right version on OSX 10.4.10 ........
1 parent e580f5c commit e4ca815

File tree

5 files changed

+33
-19
lines changed

5 files changed

+33
-19
lines changed

.bzrignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.purify
1+
´.purify
22
autom4te.cache
33
config.log
44
config.cache
@@ -41,3 +41,7 @@ Modules/Setup.local
4141
Modules/config.c
4242
Parser/pgen
4343
Lib/plat-mac/errors.rsrc.df.rsrc
44+
Lib/lib2to3/Grammar2.6.0.alpha.1.pickle
45+
Lib/lib2to3/Grammar2.6.0.alpha.2.pickle
46+
Lib/lib2to3/PatternGrammar2.6.0.alpha.1.pickle
47+
Lib/lib2to3/PatternGrammar2.6.0.alpha.2.pickle

Doc/library/collections.rst

+9-10
Original file line numberDiff line numberDiff line change
@@ -550,16 +550,6 @@ by the :mod:`csv` or :mod:`sqlite3` modules::
550550
for emp in map(EmployeeRecord._make, cursor.fetchall()):
551551
print(emp.name, emp.title)
552552

553-
Named tuples can also be used to generate enumerated constants:
554-
555-
.. testcode::
556-
557-
def enum(*names):
558-
return namedtuple('Enum', ' '.join(names))(*range(len(names)))
559-
560-
Status = enum('open', 'pending', 'closed')
561-
assert (0, 1, 2) == (Status.open, Status.pending, Status.closed)
562-
563553
In addition to the methods inherited from tuples, named tuples support
564554
three additional methods and one attribute. To prevent conflicts with
565555
field names, the method and attribute names start with an underscore.
@@ -655,6 +645,15 @@ customize a prototype instance:
655645
>>> default_account = Account('<owner name>', 0.0, 0)
656646
>>> johns_account = default_account._replace(owner='John')
657647

648+
Enumerated constants can be implemented with named tuples, but it is simpler
649+
and more efficient to use a simple class declaration:
650+
651+
>>> Status = namedtuple('Status', 'open pending closed')._make(range(3))
652+
>>> Status.open, Status.pending, Status.closed
653+
(0, 1, 2)
654+
>>> class Status:
655+
... open, pending, closed = range(3)
656+
658657
.. rubric:: Footnotes
659658

660659
.. [#] For information on the double-star-operator see

Lib/json/encoder.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"""
33

44
import re
5+
import math
56

67
try:
78
from _json import encode_basestring_ascii as c_encode_basestring_ascii
@@ -25,20 +26,19 @@
2526
for i in range(0x20):
2627
ESCAPE_DCT.setdefault(chr(i), '\\u{0:04x}'.format(i))
2728

28-
# Assume this produces an infinity on all machines (probably not guaranteed)
29-
INFINITY = float('1e66666')
3029
FLOAT_REPR = repr
3130

3231
def floatstr(o, allow_nan=True):
3332
# Check for specials. Note that this type of test is processor- and/or
3433
# platform-specific, so do tests which don't depend on the internals.
3534

36-
if o != o:
35+
if math.isnan(o):
3736
text = 'NaN'
38-
elif o == INFINITY:
39-
text = 'Infinity'
40-
elif o == -INFINITY:
41-
text = '-Infinity'
37+
elif math.isinf(o):
38+
if math.copysign(1., o) == 1.:
39+
text = 'Infinity'
40+
else:
41+
text = '-Infinity'
4242
else:
4343
return FLOAT_REPR(o)
4444

Lib/platform.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,17 @@ def mac_ver(release='',versioninfo=('','',''),machine=''):
720720
major = (sysv & 0xFF00) >> 8
721721
minor = (sysv & 0x00F0) >> 4
722722
patch = (sysv & 0x000F)
723-
release = '%s.%i.%i' % (_bcd2str(major),minor,patch)
723+
724+
if (major, minor) >= (10, 4):
725+
# the 'sysv' gestald cannot return patchlevels
726+
# higher than 9. Apple introduced 3 new
727+
# gestalt codes in 10.4 to deal with this
728+
# issue (needed because patch levels can
729+
# run higher than 9, such as 10.4.11)
730+
major,minor,patch = _mac_ver_lookup(('sys1','sys2','sys3'))
731+
release = '%i.%i.%i' %(major, minor, patch)
732+
else:
733+
release = '%s.%i.%i' % (_bcd2str(major),minor,patch)
724734
if sysu:
725735
major = int((sysu & 0xFF000000) >> 24)
726736
minor = (sysu & 0x00F00000) >> 20

PCbuild/pcbuild.sln

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_buildinfo", "make_buil
2929
EndProject
3030
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{553EC33E-9816-4996-A660-5D6186A0B0B3}"
3131
ProjectSection(SolutionItems) = preProject
32+
..\Modules\getbuildinfo.c = ..\Modules\getbuildinfo.c
3233
readme.txt = readme.txt
3334
EndProjectSection
3435
EndProject

0 commit comments

Comments
 (0)