]> granicus.if.org Git - python/commitdiff
Fixed a caching bug in platform.platform() where the argument of 'terse' was
authorBrett Cannon <bcannon@gmail.com>
Thu, 25 Mar 2004 16:55:12 +0000 (16:55 +0000)
committerBrett Cannon <bcannon@gmail.com>
Thu, 25 Mar 2004 16:55:12 +0000 (16:55 +0000)
not taken into consideration when caching value.

Lib/platform.py
Misc/NEWS

index 389e50cb2c7bf5fdbbe6a80088fcfc461d85ce15..7015044db3b154a374fa965db171025cc9e697fd 100755 (executable)
@@ -1135,8 +1135,8 @@ def python_compiler():
 
 ### The Opus Magnum of platform strings :-)
 
-_platform_cache = None
-_platform_aliased_cache = None
+_platform_cache = {True:None, False:None}
+_platform_aliased_cache = {True:None, False:None}
 
 def platform(aliased=0, terse=0):
 
@@ -1159,10 +1159,10 @@ def platform(aliased=0, terse=0):
     """
     global _platform_cache,_platform_aliased_cache
 
-    if not aliased and (_platform_cache is not None):
-        return _platform_cache
-    elif _platform_aliased_cache is not None:
-        return _platform_aliased_cache
+    if not aliased and (_platform_cache[bool(terse)] is not None):
+        return _platform_cache[bool(terse)]
+    elif _platform_aliased_cache[bool(terse)] is not None:
+        return _platform_aliased_cache[bool(terse)]
 
     # Get uname information and then apply platform specific cosmetics
     # to it...
@@ -1219,11 +1219,11 @@ def platform(aliased=0, terse=0):
             platform = _platform(system,release,machine,processor,bits,linkage)
 
     if aliased:
-        _platform_aliased_cache = platform
+        _platform_aliased_cache[bool(terse)] = platform
     elif terse:
         pass
     else:
-        _platform_cache = platform
+        _platform_cache[bool(terse)] = platform
     return platform
 
 ### Command line interface
index 724ccab02a01f351cb571ca0cbc1a2605f0dd2f3..9fc3ba7e80d2e2c7b7e9c3a2c5cdd35b6e052716 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -283,7 +283,7 @@ Extension modules
   into groups sharing the same key (as determined by a key function).
   It offers some of functionality of SQL's groupby keyword and of
   the Unix uniq filter.
-                                                                  
+
 - itertools now has a new function, tee() which produces two independent
   iterators from a single iterable.
 
@@ -296,6 +296,9 @@ Extension modules
 Library
 -------
 
+- Fixed a caching bug in platform.platform() where the argument of 'terse' was
+  not taken into consideration when caching value.
+
 - Added two new command-line arguments for profile (output file and
   default sort).