[pypy-svn] r77357 - in pypy/branch/fast-forward/pypy: module/_ssl module/_ssl/test rpython/tool

afa at codespeak.net afa at codespeak.net
Fri Sep 24 19:54:49 CEST 2010


Author: afa
Date: Fri Sep 24 19:54:47 2010
New Revision: 77357

Modified:
   pypy/branch/fast-forward/pypy/module/_ssl/__init__.py
   pypy/branch/fast-forward/pypy/module/_ssl/interp_ssl.py
   pypy/branch/fast-forward/pypy/module/_ssl/test/test_ssl.py
   pypy/branch/fast-forward/pypy/rpython/tool/rffi_platform.py
Log:
Add various constants: _ssl.OPENSSL_VERSION*


Modified: pypy/branch/fast-forward/pypy/module/_ssl/__init__.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_ssl/__init__.py	(original)
+++ pypy/branch/fast-forward/pypy/module/_ssl/__init__.py	Fri Sep 24 19:54:47 2010
@@ -16,7 +16,7 @@
         from pypy.module._ssl.interp_ssl import constants, HAVE_OPENSSL_RAND
 
         for constant, value in constants.iteritems():
-            Module.interpleveldefs[constant] = "space.wrap(%r)" % value
+            Module.interpleveldefs[constant] = "space.wrap(%r)" % (value,)
 
         if HAVE_OPENSSL_RAND:
             Module.interpleveldefs['RAND_add'] = "interp_ssl.RAND_add"

Modified: pypy/branch/fast-forward/pypy/module/_ssl/interp_ssl.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_ssl/interp_ssl.py	(original)
+++ pypy/branch/fast-forward/pypy/module/_ssl/interp_ssl.py	Fri Sep 24 19:54:47 2010
@@ -69,6 +69,8 @@
 
     OPENSSL_VERSION_NUMBER = rffi_platform.ConstantInteger(
         "OPENSSL_VERSION_NUMBER")
+    SSLEAY_VERSION = rffi_platform.DefinedConstantString(
+        "SSLEAY_VERSION", "SSLeay_version(SSLEAY_VERSION)")
     SSL_FILETYPE_PEM = rffi_platform.ConstantInteger("SSL_FILETYPE_PEM")
     SSL_OP_ALL = rffi_platform.ConstantInteger("SSL_OP_ALL")
     SSL_VERIFY_NONE = rffi_platform.ConstantInteger("SSL_VERIFY_NONE")
@@ -111,6 +113,16 @@
 constants["SSL_ERROR_EOF"] = PY_SSL_ERROR_EOF
 constants["SSL_ERROR_INVALID_ERROR_CODE"] = PY_SSL_ERROR_INVALID_ERROR_CODE
 
+constants["OPENSSL_VERSION_NUMBER"] = OPENSSL_VERSION_NUMBER
+ver = OPENSSL_VERSION_NUMBER
+ver, status = divmod(ver, 16)
+ver, patch  = divmod(ver, 256)
+ver, fix    = divmod(ver, 256)
+ver, minor  = divmod(ver, 256)
+ver, major  = divmod(ver, 256)
+constants["OPENSSL_VERSION_INFO"] = (major, minor, fix, patch, status)
+constants["OPENSSL_VERSION"] = SSLEAY_VERSION
+
 def ssl_external(name, argtypes, restype, **kw):
     kw['compilation_info'] = eci
     globals()['libssl_' + name] = rffi.llexternal(

Modified: pypy/branch/fast-forward/pypy/module/_ssl/test/test_ssl.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_ssl/test/test_ssl.py	(original)
+++ pypy/branch/fast-forward/pypy/module/_ssl/test/test_ssl.py	Fri Sep 24 19:54:47 2010
@@ -26,6 +26,12 @@
         assert isinstance(_ssl.SSL_ERROR_WANT_CONNECT, int)
         assert isinstance(_ssl.SSL_ERROR_EOF, int)
         assert isinstance(_ssl.SSL_ERROR_INVALID_ERROR_CODE, int)
+
+        assert isinstance(_ssl.OPENSSL_VERSION_NUMBER, int)
+        assert isinstance(_ssl.OPENSSL_VERSION_INFO, tuple)
+        assert len(_ssl.OPENSSL_VERSION_INFO) == 5
+        assert isinstance(_ssl.OPENSSL_VERSION, str)
+        assert 'openssl' in _ssl.OPENSSL_VERSION.lower()
     
     def test_RAND_add(self):
         import _ssl

Modified: pypy/branch/fast-forward/pypy/rpython/tool/rffi_platform.py
==============================================================================
--- pypy/branch/fast-forward/pypy/rpython/tool/rffi_platform.py	(original)
+++ pypy/branch/fast-forward/pypy/rpython/tool/rffi_platform.py	Fri Sep 24 19:54:47 2010
@@ -438,14 +438,14 @@
 class DefinedConstantString(CConfigEntry):
     """
     """
-    def __init__(self, macro):
+    def __init__(self, macro, name=None):
         self.macro = macro
-        self.name = macro
+        self.name = name or macro
 
     def prepare_code(self):
         yield '#ifdef %s' % self.macro
         yield 'int i;'
-        yield 'char *p = %s;' % self.macro
+        yield 'char *p = %s;' % self.name
         yield 'dump("defined", 1);'
         yield 'for (i = 0; p[i] != 0; i++ ) {'
         yield '  printf("value_%d: %d\\n", i, (int)(unsigned char)p[i]);'



More information about the Pypy-commit mailing list