After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 341114 - pygst.require uses asserts rather than real error checking
pygst.require uses asserts rather than real error checking
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-python
0.10.2
Other All
: Normal minor
: 0.10.5
Assigned To: GStreamer Maintainers
Johan (not receiving bugmail) Dahlin
Depends on:
Blocks:
 
 
Reported: 2006-05-09 09:15 UTC by Joe Wreschnig
Modified: 2006-06-09 17:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Raise a custom. compatible error explicitly, rather than using assert. (1.67 KB, patch)
2006-05-12 18:46 UTC, Joe Wreschnig
none Details | Review

Description Joe Wreschnig 2006-05-09 09:15:53 UTC
+++ This bug was initially created as a clone of Bug #341113 +++

pygst.require uses the assert keyword to check if the requested version is available, and doesn't conflict with a previous requested one. However, assert statements in Python are stripped when using python -O, and so can't be used for real run-time sanity checks. They should be replaced by conditionals that raise appropriate error types (probably ValueError, or a custom subclass of it).

Example:
piman@toybox:~$ python -O
Python 2.3.5 (#2, Mar  6 2006, 10:12:24)
[GCC 4.0.3 20060304 (prerelease) (Debian 4.0.2-10)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gst
>>> import pygst
>>> pygst.require("0.8")
>>> pygst.require("0.10")
>>>
Comment 1 Thomas Vander Stichele 2006-05-11 20:50:17 UTC
what does pygtk do for this ?
Comment 2 Edward Hervey 2006-05-12 07:32:56 UTC
The bug this one was cloned from (#341113) is the same thing for pygtk. I'll chat with Johan about the implications.
Comment 3 Joe Wreschnig 2006-05-12 08:00:43 UTC
If there's some concern for API compatibility (though note the previous API was unreliably broken in the first place), the error raised could be a subclass of both ValueError and AssertionError. Then both the new except ValueError: and the old except AssertionError: would catch the issue.
Comment 4 Joe Wreschnig 2006-05-12 18:46:55 UTC
Created attachment 65342 [details] [review]
Raise a custom. compatible error explicitly, rather than using assert.
Comment 5 Edward Hervey 2006-06-09 17:21:46 UTC
cvs version was already raising a AssertionError, but your patch is cleaner and more compatible.

Commited to cvs.

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