[Python-bugs-list] [ python-Bugs-636485 ] undefined SSL_ERROR_EOF in SSLFile._read

noreply@sourceforge.net noreply@sourceforge.net
Mon, 11 Nov 2002 22:00:50 -0800


Bugs item #636485, was opened at 2002-11-11 07:39
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=636485&group_id=5470

Category: Python Library
>Group: 3rd Party
>Status: Closed
>Resolution: Works For Me
Priority: 5
Submitted By: Michael Scharf (scharf)
Assigned to: Nobody/Anonymous (nobody)
Summary: undefined SSL_ERROR_EOF in SSLFile._read

Initial Comment:
  File "c:\Python22\lib\httplib.py", line 840, in _read
              if (err[0] == 
socket.SSL_ERROR_ZERO_RETURN
                   AttributeError: 'module' object has no 
attribute 'SSL_ERROR_EOF' Traceback (most recent 
call last):     

tested:
  Python 2.2.1 (#1, Jun 25 2002, 10:55:46) 
  [GCC 2.95.3-5 (cygwin special)] on cygwin
and 
  Python 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 
bit (Intel)] on win32
  with http://www.cs.fhm.edu/~ifw00065/pyssl/index.html



----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2002-11-12 07:00

Message:
Logged In: YES 
user_id=21627

My code snippet is from the Python 2.2.2 source code, from
Modules/socketmodule.c. This code is not used on Windows,
but httplib is designed to work with it (on Unix).

So this is clearly a bug in pyopenssl. Closing as third-party.

----------------------------------------------------------------------

Comment By: Michael Scharf (scharf)
Date: 2002-11-12 04:13

Message:
Logged In: YES 
user_id=71965

I use the normal win32 python distribution
http://www.python.org/ftp/python/2.2.2/Python-2.2.2.exe For
cygwin I use the python2.2.1 (the one that the cygwin-setup
installes)

>From http://pyopenssl.sourceforge.net/ I have instelled:
http://prdownloads.sourceforge.net/pyopenssl/pyOpenSSL-0.4.1.win32-py2.2.exe?download

It seems that the cygwin python uses the same ssl
implementation.

So the bug is probably in pyopenssl.  Here is MY cygwin
output:
$ python
Python 2.2.1 (#1, Jun 25 2002, 10:55:46) 
[GCC 2.95.3-5 (cygwin special)] on cygwin
Type "help", "copyright", "credits" or "license" for more
information.
>>> import socket
>>> filter(lambda x:x.find("SSL_")==0,dir(socket)) 
['SSL_ERROR_SSL', 'SSL_ERROR_SYSCALL',
'SSL_ERROR_WANT_READ', 'SSL_ERROR_WANT_WRITE',
'SSL_ERROR_WANT_X509_LOOKUP', 'SSL_ERROR_ZERO_RETURN']

looking into the sourcecode of
http://prdownloads.sourceforge.net/pyopenssl/pyOpenSSL-0.5.1.tar.gz?download
and
http://prdownloads.sourceforge.net/pyopenssl/pyOpenSSL-0.4.1.tar.gz?download
in file file src/ssl/ssl.c:

/*
 * ADD_EXCEPTION(dict,name,base) expands to a correct
Exception declaration,
 * inserting OpenSSL.SSL.name into dict, derviving the
exception from base.
 */
#define ADD_EXCEPTION(_name, _base)                        
           \
do {                                                       
                  \
    ssl_##_name = PyErr_NewException("SSL."#_name, _base,
NULL);\
    if (ssl_##_name == NULL)                               
            \
        goto error;                                        
                  \
    if (PyModule_AddObject(module, #_name, ssl_##_name) !=
0)           \
        goto error;                                        
                  \
} while (0)

    ssl_Error = PyErr_NewException("SSL.Error", NULL, NULL);
    if (ssl_Error == NULL)
        goto error;
    if (PyModule_AddObject(module, "Error", ssl_Error) != 0)
        goto error;

    ADD_EXCEPTION(ZeroReturnError,     ssl_Error);
    ADD_EXCEPTION(WantReadError,       ssl_Error);
    ADD_EXCEPTION(WantWriteError,      ssl_Error);
    ADD_EXCEPTION(WantX509LookupError, ssl_Error);
    ADD_EXCEPTION(SysCallError,        ssl_Error);
#undef ADD_EXCEPTION


Which version of SSL is your code snippet taken from?
I did not know that there are multipe OpenSSL for python.
So, maybe I should report the bug to
http://pyopenssl.sourceforge.net ...

Michael

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2002-11-11 18:52

Message:
Logged In: YES 
user_id=21627

By "win32", do you mean the PythonLabs binary? This does not
support OpenSSL (and defines no SSL_ERROR_ constants at
all), so it is not clear to me what binary you are using.

Same for Cygwin. Python 2.2 has this code

        PyModule_AddIntConstant(m, "SSL_ERROR_SSL",
                                PY_SSL_ERROR_SSL);
        PyModule_AddIntConstant(m, "SSL_ERROR_WANT_CONNECT",
                                PY_SSL_ERROR_WANT_CONNECT);
        /* non ssl.h errorcodes */
        PyModule_AddIntConstant(m, "SSL_ERROR_EOF",
                                PY_SSL_ERROR_EOF);

So there is absolutely *no* way that SSL_ERROR_SSL is
defined, but SSL_ERROR_EOF is not - unless somebody modified
the source code.


----------------------------------------------------------------------

Comment By: Michael Scharf (scharf)
Date: 2002-11-11 18:26

Message:
Logged In: YES 
user_id=71965

on cygwin:
SSL_ERROR_SSL
SSL_ERROR_SYSCALL
SSL_ERROR_WANT_READ
SSL_ERROR_WANT_WRITE
SSL_ERROR_WANT_X509_LOOKUP
SSL_ERROR_ZERO_RETURN

on win32 (the same):
SSL_ERROR_SSL
SSL_ERROR_SYSCALL
SSL_ERROR_WANT_READ
SSL_ERROR_WANT_WRITE
SSL_ERROR_WANT_X509_LOOKUP
SSL_ERROR_ZERO_RETURN

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2002-11-11 14:52

Message:
Logged In: YES 
user_id=21627

That is very strange. Can you please report all symbols in
module socket that start with SSL_ERROR_?


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=636485&group_id=5470