[Python-checkins] r54046 - in python/branches/p3yk_no_args_on_exc: BROKEN Lib/socket.py Misc/NEWS Modules/_ssl.c Modules/socketmodule.c Python/errors.c
brett.cannon
python-checkins at python.org
Thu Mar 1 00:31:22 CET 2007
Author: brett.cannon
Date: Thu Mar 1 00:31:14 2007
New Revision: 54046
Modified:
python/branches/p3yk_no_args_on_exc/BROKEN
python/branches/p3yk_no_args_on_exc/Lib/socket.py
python/branches/p3yk_no_args_on_exc/Misc/NEWS
python/branches/p3yk_no_args_on_exc/Modules/_ssl.c
python/branches/p3yk_no_args_on_exc/Modules/socketmodule.c
python/branches/p3yk_no_args_on_exc/Python/errors.c
Log:
Fix the BaseException.args removal. Required wrapping tuple arguments to
PyErr_SetObject() within another tuple, else PyErr_Fetch() passes the tuple
directly to the exception's init function which raising an exception itself
since only one argument is allowed. Also had to tweak PyErr_SetFromErrno() to
do the same thing.
Modified: python/branches/p3yk_no_args_on_exc/BROKEN
==============================================================================
--- python/branches/p3yk_no_args_on_exc/BROKEN (original)
+++ python/branches/p3yk_no_args_on_exc/BROKEN Thu Mar 1 00:31:14 2007
@@ -1,10 +1,9 @@
-* Construction of exception at C level passing too many arguments?
+* socket.error is passed two arguments but just subclasses PyExc_Exception, and
+ thus constructor gets passed two arguments (thanks to
+ PyErr_NormalizeException() passing any tuple given to it as a value as the
+ args tuple, but not when it is any other type of value).
+ test_bsddb
- + test_socket
- + test_socket_ssl
- + test_timeout
- + test_urllib2net
- + test_urllibnet
+ + test_bsddb3 (?)
* doctest oddness (need to change how SyntaxError is handled?)
+ test_xml_etree
Modified: python/branches/p3yk_no_args_on_exc/Lib/socket.py
==============================================================================
--- python/branches/p3yk_no_args_on_exc/Lib/socket.py (original)
+++ python/branches/p3yk_no_args_on_exc/Lib/socket.py Thu Mar 1 00:31:14 2007
@@ -138,7 +138,7 @@
class _closedsocket(object):
__slots__ = []
def _dummy(*args):
- raise error(EBADF, 'Bad file descriptor')
+ raise error((EBADF, 'Bad file descriptor'))
def close(self):
pass
# All _delegate_methods must also be initialized here.
Modified: python/branches/p3yk_no_args_on_exc/Misc/NEWS
==============================================================================
--- python/branches/p3yk_no_args_on_exc/Misc/NEWS (original)
+++ python/branches/p3yk_no_args_on_exc/Misc/NEWS Thu Mar 1 00:31:14 2007
@@ -28,6 +28,9 @@
Core and Builtins
-----------------
+- PyErr_SetFromErrno() now wraps its value argument in another tuple before
+ passing it to the exception type's init function.
+
- SyntaxError now enforces the requirement of having two arguments, second of
which is a four-item tuple.
Modified: python/branches/p3yk_no_args_on_exc/Modules/_ssl.c
==============================================================================
--- python/branches/p3yk_no_args_on_exc/Modules/_ssl.c (original)
+++ python/branches/p3yk_no_args_on_exc/Modules/_ssl.c Thu Mar 1 00:31:14 2007
@@ -161,19 +161,18 @@
n = PyInt_FromLong((long) p);
if (n == NULL)
return NULL;
- v = PyTuple_New(2);
- if (v == NULL) {
- Py_DECREF(n);
- return NULL;
- }
s = PyString_FromString(errstr);
if (s == NULL) {
- Py_DECREF(v);
Py_DECREF(n);
}
- PyTuple_SET_ITEM(v, 0, n);
- PyTuple_SET_ITEM(v, 1, s);
+ v = Py_BuildValue("((O, O))", n, s);
+ if (v == NULL) {
+ Py_DECREF(n);
+ Py_DECREF(s);
+ return NULL;
+ }
+
PyErr_SetObject(PySSLErrorObject, v);
Py_DECREF(v);
return NULL;
Modified: python/branches/p3yk_no_args_on_exc/Modules/socketmodule.c
==============================================================================
--- python/branches/p3yk_no_args_on_exc/Modules/socketmodule.c (original)
+++ python/branches/p3yk_no_args_on_exc/Modules/socketmodule.c Thu Mar 1 00:31:14 2007
@@ -531,7 +531,7 @@
}
}
- v = Py_BuildValue("(is)", err_no, msg);
+ v = Py_BuildValue("((is))", err_no, msg);
if (v != NULL) {
PyErr_SetObject(socket_error, v);
Py_DECREF(v);
@@ -567,7 +567,7 @@
*lastc-- = '\0';
}
}
- v = Py_BuildValue("(is)", myerrorcode, outbuf);
+ v = Py_BuildValue("((is))", myerrorcode, outbuf);
if (v != NULL) {
PyErr_SetObject(socket_error, v);
Py_DECREF(v);
@@ -580,7 +580,7 @@
#if defined(RISCOS)
if (_inet_error.errnum != NULL) {
PyObject *v;
- v = Py_BuildValue("(is)", errno, _inet_err());
+ v = Py_BuildValue("((is))", errno, _inet_err());
if (v != NULL) {
PyErr_SetObject(socket_error, v);
Py_DECREF(v);
@@ -599,9 +599,9 @@
PyObject *v;
#ifdef HAVE_HSTRERROR
- v = Py_BuildValue("(is)", h_error, (char *)hstrerror(h_error));
+ v = Py_BuildValue("((is))", h_error, (char *)hstrerror(h_error));
#else
- v = Py_BuildValue("(is)", h_error, "host not found");
+ v = Py_BuildValue("((is))", h_error, "host not found");
#endif
if (v != NULL) {
PyErr_SetObject(socket_herror, v);
@@ -624,9 +624,9 @@
#endif
#ifdef HAVE_GAI_STRERROR
- v = Py_BuildValue("(is)", error, gai_strerror(error));
+ v = Py_BuildValue("((is))", error, gai_strerror(error));
#else
- v = Py_BuildValue("(is)", error, "getaddrinfo failed");
+ v = Py_BuildValue("((is))", error, "getaddrinfo failed");
#endif
if (v != NULL) {
PyErr_SetObject(socket_gaierror, v);
Modified: python/branches/p3yk_no_args_on_exc/Python/errors.c
==============================================================================
--- python/branches/p3yk_no_args_on_exc/Python/errors.c (original)
+++ python/branches/p3yk_no_args_on_exc/Python/errors.c Thu Mar 1 00:31:14 2007
@@ -335,9 +335,9 @@
#endif /* Unix/Windows */
#endif /* PLAN 9*/
if (filenameObject != NULL)
- v = Py_BuildValue("(isO)", i, s, filenameObject);
+ v = Py_BuildValue("((isO))", i, s, filenameObject);
else
- v = Py_BuildValue("(is)", i, s);
+ v = Py_BuildValue("((is))", i, s);
if (v != NULL) {
PyErr_SetObject(exc, v);
Py_DECREF(v);
@@ -415,9 +415,9 @@
s[--len] = '\0';
}
if (filenameObject != NULL)
- v = Py_BuildValue("(isO)", err, s, filenameObject);
+ v = Py_BuildValue("((isO))", err, s, filenameObject);
else
- v = Py_BuildValue("(is)", err, s);
+ v = Py_BuildValue("((is))", err, s);
if (v != NULL) {
PyErr_SetObject(exc, v);
Py_DECREF(v);
More information about the Python-checkins
mailing list