This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Unsupported provider

classification
Title: Give access to openssl version number
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, flox, giampaolo.rodola, janssen, loewis, pitrou
Priority: normal Keywords: patch

Created on 2010-04-05 20:42 by pitrou, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
sslversion.patch pitrou, 2010-04-05 21:12
Messages (12)
msg102406 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-04-05 20:42
This patch gives access to the OpenSSL version the _ssl module is linked against, through three attributes: one gives the raw integer, another the decoded 5-tuple of ints, the last one the version string as returned by OpenSSL.
msg102408 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-04-05 20:44
(note: tested with OpenSSL 0.9.8k and 1.0.0)
msg102411 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2010-04-05 20:46
Can you please add documentation as well?
msg102413 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-04-05 21:10
New patch with doc.
msg102415 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2010-04-05 21:20
I was about to open a request for this.
Thanks.
msg102417 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-04-05 21:46
Committed, with Benjamin's permission, in r79812 (trunk) and r79813 (py3k).
msg102418 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2010-04-05 21:57
>>> import ssl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/ssl.py", line 62, in <module>
    from _ssl import OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_INFO, OPENSSL_VERSION
ImportError: cannot import name OPENSSL_VERSION_NUMBER



Just in case it's my fault, here's what I've done before importing ssl module:

> svn up 
Updated to revision 79814.
> make distclean
...
> ./configure ; make ; make install
...
msg102419 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-04-05 22:05
> >>> import ssl
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "/usr/local/lib/python2.7/ssl.py", line 62, in <module>
>     from _ssl import OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_INFO, OPENSSL_VERSION
> ImportError: cannot import name OPENSSL_VERSION_NUMBER

This looks rather unlikely.
Can you type "import _ssl" and then check _ssl.__file__ to see if it's
the one that's just been compiled?
Or did compilation fail?
msg102420 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2010-04-05 22:15
The ./configure -> make -> make install process went fine, or at least, I think so, as it completed without reporting errors or exiting.
...But maybe I'm doing something wrong as just a little while ago I was modifying _ssl.c but wasn't able to see those changes applied.

So I'm gonna ask: when I modify *.c files, do I have to do something else other than "./configure; make; make install" in order to see the changes applied?

Anyway, here's what you asked:


root@ubuntu:/home/giampaolo/svn/python-2.7# python
Python 2.7a4+ (trunk:79814, Apr  5 2010, 23:53:01) 
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import _ssl
>>> _ssl
<module '_ssl' from '/usr/local/lib/python2.7/lib-dynload/_ssl.so'>
>>> _ssl.__file__
'/usr/local/lib/python2.7/lib-dynload/_ssl.so'
>>>
msg102421 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-04-05 22:21
> So I'm gonna ask: when I modify *.c files, do I have to do something
> else other than "./configure; make; make install" in order to see the
> changes applied?

No.

If you run the Python binary from the SVN checkout directory (rather
than from an installation), _ssl should come from the build
subdirectory, not from /usr/local/lib.
Example here:

$ pwd
/home/antoine/cpython/newssl
$ ./python -c "import _ssl; print _ssl.__file__"
/home/antoine/cpython/newssl/build/lib.linux-x86_64-2.7/_ssl.so

If _ssl is coming from "/usr/local/lib/...", it means that something
modifies your sys.path so as to put that path before the path to the
just built extension modules. I can't really investigate this point for
you, but try using "python -E" instead.
msg102422 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-04-05 22:29
> So I'm gonna ask: when I modify *.c files, do I have to do something
> else other than "./configure; make; make install" in order to see the
> changes applied?

Oh, sorry, I had overlooked the "make install" bit.
Well then I don't know. But you can run the interpreter without
installing :-) (just "./python")

And check the output of "make" after you have touched Modules/_ssl.c
msg102425 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2010-04-05 22:56
You were right: make output had an error involving ssl I didn't notice. My bad.
History
Date User Action Args
2022-04-11 14:56:59adminsetgithub: 52568
2010-04-05 22:56:26giampaolo.rodolasetmessages: + msg102425
2010-04-05 22:29:49pitrousetmessages: + msg102422
2010-04-05 22:21:43pitrousetmessages: + msg102421
2010-04-05 22:15:13giampaolo.rodolasetmessages: + msg102420
2010-04-05 22:05:38pitrousetmessages: + msg102419
2010-04-05 21:57:16giampaolo.rodolasetmessages: + msg102418
2010-04-05 21:46:20pitrousetstatus: open -> closed
resolution: fixed
messages: + msg102417

stage: patch review -> resolved
2010-04-05 21:20:56giampaolo.rodolasetmessages: + msg102415
2010-04-05 21:12:16pitrousetfiles: + sslversion.patch
2010-04-05 21:11:57pitrousetfiles: - sslversion.patch
2010-04-05 21:10:53pitrousetfiles: + sslversion.patch

messages: + msg102413
2010-04-05 21:10:26pitrousetfiles: - sslversion.patch
2010-04-05 20:46:55loewissetnosy: + loewis
messages: + msg102411
2010-04-05 20:44:01pitrousetmessages: + msg102408
2010-04-05 20:42:52pitroucreate