[Python-3000-checkins] r62874 - in python/branches/py3k: .bzrignore Doc/library/collections.rst Lib/json/encoder.py Lib/platform.py PCbuild/pcbuild.sln
christian.heimes
python-3000-checkins at python.org
Thu May 8 19:18:53 CEST 2008
Author: christian.heimes
Date: Thu May 8 19:18:53 2008
New Revision: 62874
Log:
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
........
Modified:
python/branches/py3k/ (props changed)
python/branches/py3k/.bzrignore
python/branches/py3k/Doc/library/collections.rst
python/branches/py3k/Lib/json/encoder.py
python/branches/py3k/Lib/platform.py
python/branches/py3k/PCbuild/pcbuild.sln
Modified: python/branches/py3k/.bzrignore
==============================================================================
--- python/branches/py3k/.bzrignore (original)
+++ python/branches/py3k/.bzrignore Thu May 8 19:18:53 2008
@@ -1,4 +1,4 @@
-.purify
+´.purify
autom4te.cache
config.log
config.cache
@@ -41,3 +41,7 @@
Modules/config.c
Parser/pgen
Lib/plat-mac/errors.rsrc.df.rsrc
+Lib/lib2to3/Grammar2.6.0.alpha.1.pickle
+Lib/lib2to3/Grammar2.6.0.alpha.2.pickle
+Lib/lib2to3/PatternGrammar2.6.0.alpha.1.pickle
+Lib/lib2to3/PatternGrammar2.6.0.alpha.2.pickle
Modified: python/branches/py3k/Doc/library/collections.rst
==============================================================================
--- python/branches/py3k/Doc/library/collections.rst (original)
+++ python/branches/py3k/Doc/library/collections.rst Thu May 8 19:18:53 2008
@@ -550,16 +550,6 @@
for emp in map(EmployeeRecord._make, cursor.fetchall()):
print(emp.name, emp.title)
-Named tuples can also be used to generate enumerated constants:
-
-.. testcode::
-
- def enum(*names):
- return namedtuple('Enum', ' '.join(names))(*range(len(names)))
-
- Status = enum('open', 'pending', 'closed')
- assert (0, 1, 2) == (Status.open, Status.pending, Status.closed)
-
In addition to the methods inherited from tuples, named tuples support
three additional methods and one attribute. To prevent conflicts with
field names, the method and attribute names start with an underscore.
@@ -655,6 +645,15 @@
>>> default_account = Account('<owner name>', 0.0, 0)
>>> johns_account = default_account._replace(owner='John')
+Enumerated constants can be implemented with named tuples, but it is simpler
+and more efficient to use a simple class declaration:
+
+ >>> Status = namedtuple('Status', 'open pending closed')._make(range(3))
+ >>> Status.open, Status.pending, Status.closed
+ (0, 1, 2)
+ >>> class Status:
+ ... open, pending, closed = range(3)
+
.. rubric:: Footnotes
.. [#] For information on the double-star-operator see
Modified: python/branches/py3k/Lib/json/encoder.py
==============================================================================
--- python/branches/py3k/Lib/json/encoder.py (original)
+++ python/branches/py3k/Lib/json/encoder.py Thu May 8 19:18:53 2008
@@ -2,6 +2,7 @@
"""
import re
+import math
try:
from _json import encode_basestring_ascii as c_encode_basestring_ascii
@@ -25,20 +26,19 @@
for i in range(0x20):
ESCAPE_DCT.setdefault(chr(i), '\\u{0:04x}'.format(i))
-# Assume this produces an infinity on all machines (probably not guaranteed)
-INFINITY = float('1e66666')
FLOAT_REPR = repr
def floatstr(o, allow_nan=True):
# Check for specials. Note that this type of test is processor- and/or
# platform-specific, so do tests which don't depend on the internals.
- if o != o:
+ if math.isnan(o):
text = 'NaN'
- elif o == INFINITY:
- text = 'Infinity'
- elif o == -INFINITY:
- text = '-Infinity'
+ elif math.isinf(o):
+ if math.copysign(1., o) == 1.:
+ text = 'Infinity'
+ else:
+ text = '-Infinity'
else:
return FLOAT_REPR(o)
Modified: python/branches/py3k/Lib/platform.py
==============================================================================
--- python/branches/py3k/Lib/platform.py (original)
+++ python/branches/py3k/Lib/platform.py Thu May 8 19:18:53 2008
@@ -720,7 +720,17 @@
major = (sysv & 0xFF00) >> 8
minor = (sysv & 0x00F0) >> 4
patch = (sysv & 0x000F)
- release = '%s.%i.%i' % (_bcd2str(major),minor,patch)
+
+ if (major, minor) >= (10, 4):
+ # the 'sysv' gestald cannot return patchlevels
+ # higher than 9. Apple introduced 3 new
+ # gestalt codes in 10.4 to deal with this
+ # issue (needed because patch levels can
+ # run higher than 9, such as 10.4.11)
+ major,minor,patch = _mac_ver_lookup(('sys1','sys2','sys3'))
+ release = '%i.%i.%i' %(major, minor, patch)
+ else:
+ release = '%s.%i.%i' % (_bcd2str(major),minor,patch)
if sysu:
major = int((sysu & 0xFF000000) >> 24)
minor = (sysu & 0x00F00000) >> 20
Modified: python/branches/py3k/PCbuild/pcbuild.sln
==============================================================================
--- python/branches/py3k/PCbuild/pcbuild.sln (original)
+++ python/branches/py3k/PCbuild/pcbuild.sln Thu May 8 19:18:53 2008
@@ -29,6 +29,7 @@
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{553EC33E-9816-4996-A660-5D6186A0B0B3}"
ProjectSection(SolutionItems) = preProject
+ ..\Modules\getbuildinfo.c = ..\Modules\getbuildinfo.c
readme.txt = readme.txt
EndProjectSection
EndProject
More information about the Python-3000-checkins
mailing list