diff options
author | Craig Rodrigues <rodrigc@FreeBSD.org> | 2015-11-13 05:46:46 -0800 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2015-11-16 21:49:54 +0100 |
commit | 4964fb10003bc8e06e546b62431e2a38a1f4a180 (patch) | |
tree | f998eb8914d46680b8e7d0e17aa0b1209d66fa29 /contrib | |
parent | 227aeb7966f9b5d41c6988cf53c05aa536334a7e (diff) | |
download | m2crypto-4964fb10003bc8e06e546b62431e2a38a1f4a180.tar.gz |
Use print as a function for Python 3. [PEP 3105]
For Python 2 compatibility, import print_function from the __future__ module.
This works as far back as Python 2.6.0a2:
https://docs.python.org/2/library/__future__.html
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/SimpleX509create.py | 13 | ||||
-rw-r--r-- | contrib/dispatcher.py | 11 | ||||
-rw-r--r-- | contrib/isaac.httpslib.py | 6 |
3 files changed, 18 insertions, 12 deletions
diff --git a/contrib/SimpleX509create.py b/contrib/SimpleX509create.py index 7f5fc67..3a7c83c 100644 --- a/contrib/SimpleX509create.py +++ b/contrib/SimpleX509create.py @@ -2,6 +2,7 @@ # #vim: ts=4 sw=4 nowrap # +from __future__ import print_function """PKI demo by Peter Teniz <peter.teniz@inverisa.net>""" @@ -71,7 +72,7 @@ class Cert: self.X509Request.set_pubkey ( pkey=self.PKey ) self.X509Request.sign ( pkey=self.PKey, md='sha1' ) - #print X509Request.as_text () + #print(X509Request.as_text ()) @@ -119,8 +120,8 @@ class Cert: X509Name = self.X509Request.get_subject () - #print X509Name.entry_count () - #print X509Name.as_text () + #print(X509Name.entry_count ()) + #print(X509Name.as_text ()) self.X509Certificate.set_subject_name( X509Name ) @@ -139,8 +140,8 @@ class Cert: X509Name.add_entry_by_txt ( field='Email', type=MBSTRING_ASC, entry='admin@localhost', len=-1, loc=-1, set=0 ) # pkcs9 email address X509Name.add_entry_by_txt ( field='emailAddress', type=MBSTRING_ASC, entry='admin@localhost', len=-1, loc=-1, set=0 ) # pkcs9 email address - #print X509Name.entry_count () - #print X509Name.as_text () + #print(X509Name.entry_count ()) + #print(X509Name.as_text ()) self.X509Certificate.set_issuer_name( X509Name ) @@ -149,7 +150,7 @@ class Cert: # self.X509Certificate.sign( pkey=self.PKey, md='sha1' ) - print self.X509Certificate.as_text () + print(self.X509Certificate.as_text ()) diff --git a/contrib/dispatcher.py b/contrib/dispatcher.py index 6e7302d..6721d56 100644 --- a/contrib/dispatcher.py +++ b/contrib/dispatcher.py @@ -1,4 +1,7 @@ #!/usr/local/bin/python -O
+
+from __future__ import print_function
+
"""
Implements a [hopefully] non-blocking SSL dispatcher on top of
M2Crypto package.
@@ -149,18 +152,18 @@ class dispatcher(asyncore.dispatcher_with_send): """Invoked on SSL connection establishment (whilst
in client mode)
"""
- print 'Unhandled handle_ssl_connect()'
+ print('Unhandled handle_ssl_connect()')
def handle_ssl_accept(self):
"""Invoked on SSL connection establishment (whilst
in server mode)
"""
- print 'Unhandled handle_ssl_accept()'
+ print('Unhandled handle_ssl_accept()')
def handle_ssl_read(self, data):
"""Invoked on new data arrival to SSL connection
"""
- print 'Unhandled handle_ssl_read event'
+ print('Unhandled handle_ssl_read event')
def handle_ssl_close(self):
"""Invoked on SSL connection termination
@@ -182,7 +185,7 @@ if __name__=='__main__': dispatcher.__init__(self, cert, key)
def handle_ssl_read(self, data):
- print data
+ print(data)
self.ssl_write('test write')
ssl = client('test.cert', 'test.key')
diff --git a/contrib/isaac.httpslib.py b/contrib/isaac.httpslib.py index 627a8fd..a5ea5e2 100644 --- a/contrib/isaac.httpslib.py +++ b/contrib/isaac.httpslib.py @@ -1,3 +1,5 @@ +from __future__ import print_function + """M2Crypto support for Python 1.5.2 and Python 2.x's httplib. Copyright (c) 1999-2002 Ng Pheng Siong. All rights reserved.""" @@ -102,7 +104,7 @@ elif sys.version[:3] == '1.5': raise socket.error("nonnumeric port") if not port: port = HTTPS_PORT self.sock = SSL.Connection(self.ssl_ctx) - if self.debuglevel > 0: print 'connect:', (host, port) + if self.debuglevel > 0: print('connect:', (host, port)) self.sock.connect((host, port)) # ISS Added. @@ -257,7 +259,7 @@ class HTTPSProxyConnection(HTTPProxyConnection): # Fake the socket ssl = socket.ssl(self.sock, self.key_file, self.cert_file) self.sock = FakeSocket(self.sock, ssl) - if self.debuglevel > 0: print 'socket type:', self.sock + if self.debuglevel > 0: print('socket type:', self.sock) def putrequest(self, method, url): """Send a request to the server. |