From: Amaury Forgeot d'Arc Date: Tue, 9 Jun 2009 22:53:16 +0000 (+0000) Subject: Avoid invoking the parser/compiler just to test the presence of a function. X-Git-Tag: v2.7a1~994 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=03dcc73c1121ebccc49af4cb5ff2d4aa8ca833db;p=thirdparty%2FPython%2Fcpython.git Avoid invoking the parser/compiler just to test the presence of a function. --- diff --git a/Lib/os.py b/Lib/os.py index abbadc41e44b..40d117e824f7 100644 --- 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"):