From: Olivier Aubert Date: Fri, 28 Aug 2009 14:34:49 +0000 (+0200) Subject: python-ctypes: accomodate both old and new message exception getter X-Git-Tag: 1.1.0-ff~3798 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=4b8fd6429bf873795a33a73b381e5e29003a8d28;p=vlc python-ctypes: accomodate both old and new message exception getter --- diff --git a/bindings/python-ctypes/header.py b/bindings/python-ctypes/header.py index 4f4c870ade..83b370f84c 100755 --- a/bindings/python-ctypes/header.py +++ b/bindings/python-ctypes/header.py @@ -91,19 +91,42 @@ class LibVLCException(Exception): pass # From libvlc_structures.h -class VLCException(ctypes.Structure): - """libvlc exception. - """ - _fields_= [ - ('raised', ctypes.c_int), - ('code', ctypes.c_int), - ('message', ctypes.c_char_p), - ] - def init(self): - libvlc_exception_init(self) - def clear(self): - libvlc_exception_clear(self) +# This is version-dependent, depending on the presence of libvlc_exception_get_message. + +if hasattr(dll, 'libvlc_exception_get_message'): + # New-style message passing + class VLCException(ctypes.Structure): + """libvlc exception. + """ + _fields_= [ + ('raised', ctypes.c_int), + ] + + @property + def message(self): + return dll.libvlc_exception_get_message() + + def init(self): + libvlc_exception_init(self) + + def clear(self): + libvlc_exception_clear(self) +else: + # Old-style exceptions + class VLCException(ctypes.Structure): + """libvlc exception. + """ + _fields_= [ + ('raised', ctypes.c_int), + ('code', ctypes.c_int), + ('message', ctypes.c_char_p), + ] + def init(self): + libvlc_exception_init(self) + + def clear(self): + libvlc_exception_clear(self) class PlaylistItem(ctypes.Structure): _fields_= [