[Python-checkins] r73324 - python/trunk/Lib/os.py

amaury.forgeotdarc python-checkins at python.org
Wed Jun 10 00:53:17 CEST 2009


Author: amaury.forgeotdarc
Date: Wed Jun 10 00:53:16 2009
New Revision: 73324

Log:
Avoid invoking the parser/compiler just to test the presence of a function.


Modified:
   python/trunk/Lib/os.py

Modified: python/trunk/Lib/os.py
==============================================================================
--- python/trunk/Lib/os.py	(original)
+++ python/trunk/Lib/os.py	Wed Jun 10 00:53:16 2009
@@ -514,11 +514,7 @@
 __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"):


More information about the Python-checkins mailing list