From 117166f2ad3af6492f00cd9d8c7db1a788ff4c1a Mon Sep 17 00:00:00 2001 From: Samuel Roberts Date: Sat, 2 Jul 2016 01:44:41 +0200 Subject: [PATCH 1/2] Add support for loading of yajl.dll on Windows Yajl built with default build settings yields yajl.dll, so make an attempt to load this. At the moment, the existing load structure has simply been duplicated to achieve this. This could be refactored into something cleaner. --- yajl/yajl_common.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/yajl/yajl_common.py b/yajl/yajl_common.py index b822bc7..64273bd 100644 --- a/yajl/yajl_common.py +++ b/yajl/yajl_common.py @@ -38,6 +38,13 @@ def load_yajl(): return cdll.LoadLibrary(yajlso) except OSError: pass + + yajlso = 'yajl.dll' + try: + return cdll.LoadLibrary(yajlso) + except OSError: + pass + raise OSError('Yajl shared object cannot be found. ' 'Please install Yajl and confirm it is on your shared lib path.') From 89ef9a4f54315dc17d263e8531d4eee634f54997 Mon Sep 17 00:00:00 2001 From: Samuel Roberts Date: Sat, 2 Jul 2016 02:23:42 +0200 Subject: [PATCH 2/2] Refactor load_yajl To reduce code duplication introduced by adding windows support in commit 117166f. List of file names is generated using a list comprehension so that the unique windows file name can be appended. Consequently, the list of file names can be iterated over and two separate cases are not needed. --- yajl/yajl_common.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/yajl/yajl_common.py b/yajl/yajl_common.py index 64273bd..a66d091 100644 --- a/yajl/yajl_common.py +++ b/yajl/yajl_common.py @@ -32,19 +32,14 @@ def load_yajl(): :returns: The yajl shared object :raises OSError: when libyajl cannot be loaded ''' - for ftype in '', '.so', '.dylib': - yajlso = 'libyajl%s' %(ftype) + fnames = ['libyajl%s' %(t) for t in ['', '.so', '.dylib']] + ['yajl.dll'] + + for yajlso in fnames: try: return cdll.LoadLibrary(yajlso) except OSError: pass - yajlso = 'yajl.dll' - try: - return cdll.LoadLibrary(yajlso) - except OSError: - pass - raise OSError('Yajl shared object cannot be found. ' 'Please install Yajl and confirm it is on your shared lib path.')