From a745e451db93eccac923d4145ac755bd3d3051f2 Mon Sep 17 00:00:00 2001 From: David Rose Date: Sun, 8 Nov 2009 21:55:56 +0000 Subject: [PATCH] protect against python 2.4 --- direct/src/ffi/DoGenPyCode.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/direct/src/ffi/DoGenPyCode.py b/direct/src/ffi/DoGenPyCode.py index 927884fc83..9d5c4f3a45 100644 --- a/direct/src/ffi/DoGenPyCode.py +++ b/direct/src/ffi/DoGenPyCode.py @@ -262,7 +262,14 @@ def generateNativeWrappers(): # the library isn't present. This is particularly necessary # in the runtime (plugin) environment, where all libraries are # not necessarily downloaded. - pandaModules.write('try:\n from %sModules import *\nexcept ImportError as err:\n if "DLL loader cannot find" not in str(err):\n raise\n\n' % (moduleName)) + if sys.version_info < (2, 5): + # In Python 2.4 and earlier, we didn't have the "except + # ImportError as err" syntax. + pandaModules.write('try:\n from %sModules import *\nexcept ImportError:\n print "Failed to import %s"\n\n' % (moduleName, moduleName)) + else: + # Try to differentiate between missing files and other + # kinds of ImportErrors. + pandaModules.write('try:\n from %sModules import *\nexcept ImportError as err:\n if "DLL loader cannot find" not in str(err):\n raise\n print "Failed to import %s"\n\n' % (moduleName, moduleName)) moduleModulesFilename = os.path.join(outputCodeDir, '%sModules.py' % (moduleName)) moduleModules = open(moduleModulesFilename, 'w')