diff options
-rw-r--r-- | .bzrignore | 6 | ||||
-rw-r--r-- | Doc/library/collections.rst | 19 | ||||
-rw-r--r-- | Lib/json/encoder.py | 14 | ||||
-rwxr-xr-x | Lib/platform.py | 12 | ||||
-rw-r--r-- | PCbuild/pcbuild.sln | 1 |
5 files changed, 33 insertions, 19 deletions
@@ -1,4 +1,4 @@ -.purify +ยด.purify autom4te.cache config.log config.cache @@ -41,3 +41,7 @@ Modules/Setup.local 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 diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst index cff07b9..e886d86 100644 --- a/Doc/library/collections.rst +++ b/Doc/library/collections.rst @@ -550,16 +550,6 @@ by the :mod:`csv` or :mod:`sqlite3` modules:: 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 @@ customize a prototype instance: >>> 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 diff --git a/Lib/json/encoder.py b/Lib/json/encoder.py index 4cb3660..fa744c9 100644 --- a/Lib/json/encoder.py +++ b/Lib/json/encoder.py @@ -2,6 +2,7 @@ """ import re +import math try: from _json import encode_basestring_ascii as c_encode_basestring_ascii @@ -25,20 +26,19 @@ ESCAPE_DCT = { 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) diff --git a/Lib/platform.py b/Lib/platform.py index 2c289d2..d5cf623 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -720,7 +720,17 @@ def mac_ver(release='',versioninfo=('','',''),machine=''): 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 diff --git a/PCbuild/pcbuild.sln b/PCbuild/pcbuild.sln index 61090b4..d534d7e 100644 --- a/PCbuild/pcbuild.sln +++ b/PCbuild/pcbuild.sln @@ -29,6 +29,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_buildinfo", "make_buil 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 |