pygst.py.in: Raise RequiredVersionError(ValueError, AssertionError) wherever applicable. This makes the new system (r...

Original commit message from CVS:
* pygst.py.in:
Raise RequiredVersionError(ValueError, AssertionError) wherever
applicable. This makes the new system (raising an error) compatible
with the old system (assertions).
Fixes #341114
This commit is contained in:
Edward Hervey 2006-06-09 17:21:40 +00:00
parent 2bd7a2b2e2
commit 098f0e4f39
2 changed files with 19 additions and 5 deletions

View file

@ -1,3 +1,11 @@
2006-06-09 Edward Hervey <edward@fluendo.com>
* pygst.py.in:
Raise RequiredVersionError(ValueError, AssertionError) wherever
applicable. This makes the new system (raising an error) compatible
with the old system (assertions).
Fixes #341114
2006-06-09 Edward Hervey <edward@fluendo.com> 2006-06-09 Edward Hervey <edward@fluendo.com>
* pygst.py.in: * pygst.py.in:

View file

@ -1,5 +1,5 @@
# -*- Mode: Python; py-indent-offset: 4 -*- # -*- Mode: Python; py-indent-offset: 4 -*-
# pygtk - Python bindings for the GTK+ widget set. # pygst - Python bindings for the GStreamer multimedia framework.
# Copyright (C) 1998-2002 James Henstridge # Copyright (C) 1998-2002 James Henstridge
# (C) 2005 Edward Hervey # (C) 2005 Edward Hervey
# #
@ -34,19 +34,25 @@ _pygst_version = '@GST_MAJORMINOR@'
_pygst_required_version = None _pygst_required_version = None
class RequiredVersionError(ValueError, AssertionError):
# AssertionError is subclassed for compatibility reasons.
pass
def require(version): def require(version):
global _pygst_required_version global _pygst_required_version
if _pygst_required_version != None: if _pygst_required_version != None:
if _pygst_required_version != version: if _pygst_required_version != version:
raise StandardError, "a different version of gst was already required" raise RequiredVersionError, "a different version of gst was already required"
else:
return return
if sys.modules.has_key('gst'): if sys.modules.has_key('gst'):
raise StandardError, "pygst.require() must be called before importing gst" raise RequiredVersionError, "pygst.require() must be called before importing gst"
if version != _pygst_version: if version != _pygst_version:
raise StandardError, "Only version '%s' is available" % _pygst_version raise RequiredVersionError, "Only version '%s' is available" % _pygst_version
# move the pygst path to the front # move the pygst path to the front
while _pygst_dir in sys.path: while _pygst_dir in sys.path: