Discussion:
[Bitpim-devel] ValueError exception
Stephen Wood
2004-12-20 06:34:53 UTC
Permalink
In prototypes.py, is there a reason why the class/exception ValueError
needs to be that particular name? It seems to conflict with the "except
ValueError" (exception on res.index) in the unescape function that I
added to prototypes.py. If the ValueError name is arbitrary, can we
change it to something else like ValueException?

Stephen
Roger Binns
2004-12-20 06:32:23 UTC
Permalink
Post by Stephen Wood
In prototypes.py, is there a reason why the class/exception ValueError
needs to be that particular name? It seems to conflict with the "except
ValueError" (exception on res.index) in the unescape function that I
added to prototypes.py. If the ValueError name is arbitrary, can we
change it to something else like ValueException?
unescape shouldn't be in that file :-) unescape (and escape) would
probably be best placed in common and named something like pppescape
and pppunescape. Then in brew and other files you can add something
like:

escape=common.pppescape

Roger
Stephen Wood
2004-12-20 13:00:17 UTC
Permalink
Post by Roger Binns
Post by Stephen Wood
In prototypes.py, is there a reason why the class/exception ValueError
needs to be that particular name? It seems to conflict with the "except
ValueError" (exception on res.index) in the unescape function that I
added to prototypes.py. If the ValueError name is arbitrary, can we
change it to something else like ValueException?
unescape shouldn't be in that file :-) unescape (and escape) would
probably be best placed in common and named something like pppescape
and pppunescape. Then in brew and other files you can add something
I will move and rename the escape functions tonight.

But my question, although no longer practical, remains. In the
ValueError in prototypes clobbering a builtin exception of the same
name?

Stephen
Roger Binns
2004-12-20 16:28:04 UTC
Permalink
Post by Stephen Wood
But my question, although no longer practical, remains. In the
ValueError in prototypes clobbering a builtin exception of the same
name?
Only in the same file. The builtin ValueError could be used as well.
You can always distinguish between the two even with your existing
code. One is __builtins__.ValueError and the other is
[prototypes.]ValueError.

If it really bugs you, feel free to change the name to something else.

Roger

Loading...