

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
2 messages in org.python.python-bugs-list[ python-Feature Requests-531145 ] so...| From | Sent On | Attachments |
|---|---|---|
| SourceForge.net | Mar 23, 2004 6:30 pm | |
| SourceForge.net | Mar 24, 2004 2:34 pm |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | [ python-Feature Requests-531145 ] socket.sslerror is not a socket.error | Actions... |
|---|---|---|
| From: | SourceForge.net (nore...@sourceforge.net) | |
| Date: | Mar 24, 2004 2:34:44 pm | |
| List: | org.python.python-bugs-list | |
Feature Requests item #531145, was opened at 2002-03-18 00:14 Message generated for change (Comment added) made by calvin You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=355470&aid=531145&group_id=5470
Category: None Group: None Status: Closed Resolution: Accepted Priority: 3 Submitted By: Wummel (calvin) Assigned to: Nobody/Anonymous (nobody) Summary: socket.sslerror is not a socket.error
Initial Comment: Python 2.1.2 (#1, Mar 16 2002, 00:56:55) [GCC 2.95.4 20011002 (Debian prerelease)] on linux2 Type "copyright", "credits" or "license" for more information.
import socket socket.sslerror <class socket.sslerror at 0x809c39c> try: raise socket.sslerror
... except socket.error: pass ... Traceback (most recent call last): File "<stdin>", line 1, in ? socket.sslerror
----------------------------------------------------------------------
Comment By: Wummel (calvin)
Date: 2004-03-24 20:35
Message: Logged In: YES user_id=9205
Hei, thanks for patching this! It seems a new Python release is nearby when such minor loose ends get tidied up :)
----------------------------------------------------------------------
Comment By: Brett Cannon (bcannon) Date: 2004-03-24 00:30
Message: Logged In: YES user_id=357491
socket.sslerror is now a subclass of socket.error thanks to extending the socket module's C API. Done in:
Misc/NEWS 1.960 Modules/socketmodule.h 1.12 Modules/socketmodule.c 1.286 Modules_ssl.c 1.16
----------------------------------------------------------------------
Comment By: Brett Cannon (bcannon) Date: 2003-05-17 03:42
Message: Logged In: YES user_id=357491
Well, I have no issue with wanting to make socket.sslerror a subclass of socket.error, but socket.sslerror is not even documented so I don't see this as an issue until socket.sslerror is documented.
So this will need a doc patch on top of any patch to make the change to socket.sslerror.
----------------------------------------------------------------------
Comment By: Michael Stone (mbrierst) Date: 2003-02-04 17:19
Message: Logged In: YES user_id=670441
If this behavior is desired, the patch below implements it. If it's not
desired, this bug sould be closed.
It isn't much work at all. test_socket and test_socket_ssl still pass fine.
The following case will work after this patch, all other combinations will work
as before:
try: raise socket.sslerror
... except socket.error: print 'caught' caught
patch (I cannot attach the file in sourceforge for some reason): Index: dist/src/Modules/socketmodule.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.h,v retrieving revision 1.8 diff -c -r1.8 socketmodule.h *** dist/src/Modules/socketmodule.h 13 Jun 2002 15:07:44 -0000 1.8 --- dist/src/Modules/socketmodule.h 4 Feb 2003 16:05:27 -0000 *************** *** 140,145 **** --- 140,146 ---- /* C API for usage by other Python modules */ typedef struct { PyTypeObject *Sock_Type; + PyObject *Sock_Error; } PySocketModule_APIObject;
/* XXX The net effect of the following appears to be to define a function Index: dist/src/Modules/socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.251 diff -c -r1.251 socketmodule.c *** dist/src/Modules/socketmodule.c 6 Jan 2003 12:41:26 -0000 1.251 --- dist/src/Modules/socketmodule.c 4 Feb 2003 16:05:43 -0000 *************** *** 3117,3122 **** --- 3117,3123 ---- PySocketModule_APIObject PySocketModuleAPI = { &sock_type, + NULL, };
*************** *** 3178,3183 **** --- 3179,3185 ---- return;
/* Export C API */ + PySocketModuleAPI.Sock_Error = socket_error; if (PyModule_AddObject(m, PySocket_CAPI_NAME, PyCObject_FromVoidPtr((void *)&PySocketModuleAPI, NULL) ) != 0) Index: dist/src/Modules/_ssl.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_ssl.c,v retrieving revision 1.9 diff -c -r1.9 _ssl.c *** dist/src/Modules/_ssl.c 27 Jan 2003 22:19:21 -0000 1.9 --- dist/src/Modules/_ssl.c 4 Feb 2003 16:05:45 -0000 *************** *** 543,549 **** SSLeay_add_ssl_algorithms();
/* Add symbols to module dict */ ! PySSLErrorObject = PyErr_NewException("socket.sslerror", NULL, NULL); if (PySSLErrorObject == NULL) return; PyDict_SetItemString(d, "sslerror", PySSLErrorObject); --- 543,549 ---- SSLeay_add_ssl_algorithms();
/* Add symbols to module dict */
! PySSLErrorObject = PyErr_NewException("socket.sslerror",
PySocketModule.Sock_Error, NULL);
if (PySSLErrorObject == NULL)
return;
PyDict_SetItemString(d, "sslerror", PySSLErrorObject);
----------------------------------------------------------------------
Comment By: Wummel (calvin) Date: 2002-11-11 18:12
Message: Logged In: YES user_id=9205
Yes, I want socket.sslerror to be a subclass of socket.error. It simplifies code layout (see my previous answer) and it follows the documentation. And yes, its work, but only a little :)
----------------------------------------------------------------------
Comment By: Gerhard H?ring (ghaering) Date: 2002-10-05 02:05
Message: Logged In: YES user_id=163326
So do you propose to make socket.sslerror a subclass of socket.error. Is this desirable? I'm not sure. Is it work? Yes.
----------------------------------------------------------------------
Comment By: Wummel (calvin) Date: 2002-03-18 21:23
Message: Logged In: YES user_id=9205
The documentation says for socket.error: "This exception is raised for socket- or address-related errors." I think socket.sslerror is such an error, because then you can write
try: sock.write("") # could be ssl-socket except socket.error: pass
The other way would be _exceptions = [socket.error] if hasattr(socket, "sslerror"): _exceptions.append(socket.sslerror) try: sock.write("") except _exceptions: pass
Anyway, I assume this is a minor "bug".
----------------------------------------------------------------------
Comment By: Martin v. L?wis (loewis) Date: 2002-03-18 11:44
Message: Logged In: YES user_id=21627
Why is this a bug?
----------------------------------------------------------------------
You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=355470&aid=531145&group_id=5470







