]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fixed a caching bug in platform.platform() where the argument of 'terse' was
authorBrett Cannon <bcannon@gmail.com>
Thu, 25 Mar 2004 16:56:14 +0000 (16:56 +0000)
committerBrett Cannon <bcannon@gmail.com>
Thu, 25 Mar 2004 16:56:14 +0000 (16:56 +0000)
not taken into consideration when caching value.

Lib/platform.py
Misc/NEWS

index 1547e1247fe7c339e84ed3d382918fc20ec99abc..54560a5be3b5e86f26ff480190396c45051aa49a 100755 (executable)
@@ -1136,8 +1136,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):
 
@@ -1160,10 +1160,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...
@@ -1220,11 +1220,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 1cbfda33b194339c0cb27ecce1d74a045f571142..bacc90991e50e88d8037b793d2c6677a51596e73 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -38,6 +38,9 @@ Core and builtins
 Library
 -------
 
+- Fixed a caching bug in platform.platform() where the argument of 'terse' was
+  not taken into consideration when caching value.
+
 - Bug #920575: A problem that _locale module segfaults on
   nl_langinfo(ERA) caused by GNU libc's illegal NULL return is fixed.