]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Avoid invoking the parser/compiler just to test the presence of a function.
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>
Tue, 9 Jun 2009 22:53:16 +0000 (22:53 +0000)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>
Tue, 9 Jun 2009 22:53:16 +0000 (22:53 +0000)
Lib/os.py

index abbadc41e44b0a44d09f04504f8554655fe3f36b..40d117e824f707c49fd0572667f3ea0e82ba0049 100644 (file)
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -514,11 +514,7 @@ def getenv(key, default=None):
 __all__.append("getenv")
 
 def _exists(name):
-    try:
-        eval(name)
-        return True
-    except NameError:
-        return False
+    return name in globals()
 
 # Supply spawn*() (probably only for Unix)
 if _exists("fork") and not _exists("spawnv") and _exists("execv"):