Message2665
| Author |
dealfaro |
| Recipients |
| Date |
2000年12月18日.22:25:07 |
| SpamBayes Score |
| Marked as misclassified |
| Message-id |
| In-reply-to |
| Content |
There are three (minor?) problems with raising
ValueError.
1) Compatibility. I had some code for 1.5.2 that
was trying to load web pages checking for various
errors, and it was expecting this error to cause
a socket error, not a value error.
2) Accuracy. ValueError can be caused by
anything. The 'non-numeric port' error is much
more informative. I don't want to catch
ValueError, because it can be caused in too
many situations. I also cannot check
myself that the port is fine, because the
port and the URL are often given by a
redirect (errors 301 and 302, if I remember
correctly). This in fact was the situation
that caused the problem.
Hence, my only real solution was to patch my version of httplib.
3) Style. I am somewhat new to Python, but I was
under the impression that, stilistically,
a ValueError was used to convey a situation that
was the fault of the programmer, while other
more specific errors were used for unexpected
situations (communication, etc). Since the
socket is the result of a URL redirection
(errors 301 or 302), the programmer is not in
a position to prevent this error by "better
checking". Hence, I would consider a
network-relted exception to be more appropriate
here.
But who am I to argue with the creator of Python?
;-)
Luca
|
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2007年08月23日 13:52:28 | admin | link | issue225744 messages |
| 2007年08月23日 13:52:28 | admin | create |
|