summaryrefslogtreecommitdiff
path: root/M2Crypto
diff options
context:
space:
mode:
authorCraig Rodrigues <rodrigc@FreeBSD.org>2015-11-17 19:55:50 -0800
committerMatěj Cepl <mcepl@cepl.eu>2016-03-20 22:19:15 +0100
commit8b33fa718947fa508f59bb8461a65e2fcb3ca6fa (patch)
tree3d1640a5d4cd34e3fb45689fa9a450d82b319fa8 /M2Crypto
parent0aa30e5df1fc0c03f29e1a438123097dfdaee242 (diff)
downloadm2crypto-8b33fa718947fa508f59bb8461a65e2fcb3ca6fa.tar.gz
Use the new absolute import syntax to fix Python 3. [PEP 328]
I used the output of "2to3 -f import M2Crypto" to figure out which imports needed to be fixed. In addition, I added "from __future__ import absolute_import" to all files that I touched. This brings in the new import behavior, and works as far back as Python 2.5.0a1. See: https://docs.python.org/3/library/__future__.html https://www.python.org/dev/peps/pep-0328/
Diffstat (limited to 'M2Crypto')
-rw-r--r--M2Crypto/ASN1.py6
-rw-r--r--M2Crypto/AuthCookie.py4
-rw-r--r--M2Crypto/BIO.py6
-rwxr-xr-xM2Crypto/BN.py4
-rw-r--r--M2Crypto/DH.py6
-rw-r--r--M2Crypto/DSA.py4
-rw-r--r--M2Crypto/EC.py4
-rw-r--r--M2Crypto/EVP.py4
-rw-r--r--M2Crypto/Err.py6
-rw-r--r--M2Crypto/PGP/PublicKey.py8
-rw-r--r--M2Crypto/PGP/PublicKeyRing.py8
-rw-r--r--M2Crypto/PGP/__init__.py10
-rw-r--r--M2Crypto/PGP/packet.py4
-rw-r--r--M2Crypto/RC4.py4
-rw-r--r--M2Crypto/RSA.py4
-rw-r--r--M2Crypto/Rand.py4
-rw-r--r--M2Crypto/SMIME.py6
-rw-r--r--M2Crypto/SSL/Connection.py10
-rw-r--r--M2Crypto/SSL/Context.py4
-rw-r--r--M2Crypto/SSL/SSLServer.py4
-rw-r--r--M2Crypto/SSL/__init__.py14
-rw-r--r--M2Crypto/SSL/cb.py4
-rw-r--r--M2Crypto/SSL/ssl_dispatcher.py4
-rw-r--r--M2Crypto/X509.py4
-rw-r--r--M2Crypto/__init__.py54
-rw-r--r--M2Crypto/callback.py4
-rw-r--r--M2Crypto/ftpslib.py4
-rw-r--r--M2Crypto/httpslib.py6
-rw-r--r--M2Crypto/m2.py4
-rw-r--r--M2Crypto/m2urllib.py6
-rw-r--r--M2Crypto/m2urllib2.py12
-rw-r--r--M2Crypto/m2xmlrpclib.py4
-rw-r--r--M2Crypto/threading.py4
-rw-r--r--M2Crypto/util.py4
34 files changed, 154 insertions, 84 deletions
diff --git a/M2Crypto/ASN1.py b/M2Crypto/ASN1.py
index f826f86..10c047a 100644
--- a/M2Crypto/ASN1.py
+++ b/M2Crypto/ASN1.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
"""
M2Crypto wrapper for OpenSSL ASN1 API.
@@ -9,8 +11,8 @@ Copyright (C) 2005 OSAF. All Rights Reserved.
import time, datetime
-import BIO
-import m2
+from . import BIO
+from . import m2
MBSTRING_FLAG = 0x1000
MBSTRING_ASC = MBSTRING_FLAG | 1
diff --git a/M2Crypto/AuthCookie.py b/M2Crypto/AuthCookie.py
index 399f34b..ef1efea 100644
--- a/M2Crypto/AuthCookie.py
+++ b/M2Crypto/AuthCookie.py
@@ -1,9 +1,11 @@
+from __future__ import absolute_import
+
"""Secure Authenticator Cookies
Copyright (c) 1999-2002 Ng Pheng Siong. All rights reserved."""
# M2Crypto
-import Rand, m2
+from . import Rand, m2
# Python. Cookie is bundled with Python 2.x.
import Cookie, binascii, re, time
diff --git a/M2Crypto/BIO.py b/M2Crypto/BIO.py
index e777d72..03f8c57 100644
--- a/M2Crypto/BIO.py
+++ b/M2Crypto/BIO.py
@@ -1,12 +1,14 @@
+from __future__ import absolute_import
+
"""M2Crypto wrapper for OpenSSL BIO API.
Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved."""
-import m2
+from . import m2
from cStringIO import StringIO
# Deprecated
-from m2 import bio_do_handshake as bio_do_ssl_handshake # noqa
+from .m2 import bio_do_handshake as bio_do_ssl_handshake
class BIOError(Exception):
diff --git a/M2Crypto/BN.py b/M2Crypto/BN.py
index ac2a781..a515dc9 100755
--- a/M2Crypto/BN.py
+++ b/M2Crypto/BN.py
@@ -1,10 +1,12 @@
+from __future__ import absolute_import
+
"""
M2Crypto wrapper for OpenSSL BN (BIGNUM) API.
Copyright (c) 2005 Open Source Applications Foundation. All rights reserved.
"""
-import m2
+from . import m2
def rand(bits, top=-1, bottom=0):
"""
diff --git a/M2Crypto/DH.py b/M2Crypto/DH.py
index 2de2cbf..60efaa0 100644
--- a/M2Crypto/DH.py
+++ b/M2Crypto/DH.py
@@ -1,9 +1,11 @@
+from __future__ import absolute_import
+
"""M2Crypto wrapper for OpenSSL DH API.
Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved."""
-from util import genparam_callback
-import BIO, Err, m2
+from .util import genparam_callback
+from . import BIO, Err, m2
class DHError(Exception): pass
diff --git a/M2Crypto/DSA.py b/M2Crypto/DSA.py
index 325e418..efa4859 100644
--- a/M2Crypto/DSA.py
+++ b/M2Crypto/DSA.py
@@ -1,4 +1,4 @@
-from __future__ import print_function
+from __future__ import absolute_import, print_function
"""
M2Crypto wrapper for OpenSSL DSA API.
@@ -10,7 +10,7 @@ from __future__ import print_function
"""
import sys
-import util, BIO, m2
+from . import util, BIO, m2
class DSAError(Exception): pass
diff --git a/M2Crypto/EC.py b/M2Crypto/EC.py
index 800a705..f27a574 100644
--- a/M2Crypto/EC.py
+++ b/M2Crypto/EC.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
"""
M2Crypto wrapper for OpenSSL ECDH/ECDSA API.
@@ -8,7 +10,7 @@ Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.
Portions copyright (c) 2005-2006 Vrije Universiteit Amsterdam.
All rights reserved."""
-import util, BIO, m2
+from . import util, BIO, m2
class ECError(Exception): pass
diff --git a/M2Crypto/EVP.py b/M2Crypto/EVP.py
index 28303bd..53ff750 100644
--- a/M2Crypto/EVP.py
+++ b/M2Crypto/EVP.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
"""M2Crypto wrapper for OpenSSL EVP API.
Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved.
@@ -7,7 +9,7 @@ Author: Heikki Toivonen
"""
from M2Crypto import Err, util, BIO, RSA
-import m2
+from . import m2
class EVPError(Exception): pass
diff --git a/M2Crypto/Err.py b/M2Crypto/Err.py
index b1e80c3..f34a998 100644
--- a/M2Crypto/Err.py
+++ b/M2Crypto/Err.py
@@ -1,9 +1,11 @@
+from __future__ import absolute_import
+
"""M2Crypto wrapper for OpenSSL Error API.
Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved."""
-import BIO
-import m2
+from . import BIO
+from . import m2
def get_error():
err = BIO.MemoryBuffer()
diff --git a/M2Crypto/PGP/PublicKey.py b/M2Crypto/PGP/PublicKey.py
index 290bc44..4c62afe 100644
--- a/M2Crypto/PGP/PublicKey.py
+++ b/M2Crypto/PGP/PublicKey.py
@@ -1,10 +1,12 @@
+from __future__ import absolute_import
+
"""M2Crypto PGP2.
Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved."""
-from constants import *
-from packet import *
-import RSA
+from .constants import *
+from .packet import *
+from . import RSA
class PublicKey:
def __init__(self, pubkey_pkt):
diff --git a/M2Crypto/PGP/PublicKeyRing.py b/M2Crypto/PGP/PublicKeyRing.py
index 1a827f1..6294c46 100644
--- a/M2Crypto/PGP/PublicKeyRing.py
+++ b/M2Crypto/PGP/PublicKeyRing.py
@@ -1,10 +1,12 @@
+from __future__ import absolute_import
+
"""M2Crypto PGP2.
Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved."""
-from constants import *
-from packet import *
-from PublicKey import *
+from .constants import *
+from .packet import *
+from .PublicKey import *
class PublicKeyRing:
def __init__(self, keyring):
diff --git a/M2Crypto/PGP/__init__.py b/M2Crypto/PGP/__init__.py
index 27fd669..9e4ed7a 100644
--- a/M2Crypto/PGP/__init__.py
+++ b/M2Crypto/PGP/__init__.py
@@ -1,14 +1,16 @@
+from __future__ import absolute_import
+
"""M2Crypto PGP2.
Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved."""
-from constants import *
+from .constants import *
-from packet import public_key_packet, trust_packet, userid_packet,\
+from .packet import public_key_packet, trust_packet, userid_packet,\
comment_packet, signature_packet, private_key_packet, cke_packet,\
pke_packet, literal_packet, packet_stream
-from PublicKey import *
-from PublicKeyRing import *
+from .PublicKey import *
+from .PublicKeyRing import *
diff --git a/M2Crypto/PGP/packet.py b/M2Crypto/PGP/packet.py
index 601312e..2f353f8 100644
--- a/M2Crypto/PGP/packet.py
+++ b/M2Crypto/PGP/packet.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
"""M2Crypto PGP2.
This module implements PGP packets per RFC1991 and various source distributions.
@@ -34,7 +36,7 @@ if sys.version_info > (3,):
from M2Crypto import EVP, RSA
from M2Crypto.util import octx_to_num
-from constants import *
+from .constants import *
_OK_VERSION = ('\002', '\003')
_OK_VALIDITY = ('\000',)
diff --git a/M2Crypto/RC4.py b/M2Crypto/RC4.py
index 64133b8..55d59c7 100644
--- a/M2Crypto/RC4.py
+++ b/M2Crypto/RC4.py
@@ -1,8 +1,10 @@
+from __future__ import absolute_import
+
"""M2Crypto wrapper for OpenSSL RC4 API.
Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved."""
-from m2 import rc4_new, rc4_free, rc4_set_key, rc4_update
+from .m2 import rc4_new, rc4_free, rc4_set_key, rc4_update
class RC4:
diff --git a/M2Crypto/RSA.py b/M2Crypto/RSA.py
index a395a3e..c193515 100644
--- a/M2Crypto/RSA.py
+++ b/M2Crypto/RSA.py
@@ -1,9 +1,11 @@
+from __future__ import absolute_import
+
"""M2Crypto wrapper for OpenSSL RSA API.
Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved."""
import sys
-import util, BIO, Err, m2
+from . import util, BIO, Err, m2
class RSAError(Exception): pass
diff --git a/M2Crypto/Rand.py b/M2Crypto/Rand.py
index 6cf5eef..19fae3c 100644
--- a/M2Crypto/Rand.py
+++ b/M2Crypto/Rand.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
"""M2Crypto wrapper for OpenSSL PRNG. Requires OpenSSL 0.9.5 and above.
Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved."""
@@ -5,7 +7,7 @@ Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved."""
__all__ = ['rand_seed', 'rand_add', 'load_file', 'save_file', 'rand_bytes',
'rand_pseudo_bytes']
-import m2
+from . import m2
rand_seed = m2.rand_seed
rand_add = m2.rand_add
diff --git a/M2Crypto/SMIME.py b/M2Crypto/SMIME.py
index e624fe9..f906ab5 100644
--- a/M2Crypto/SMIME.py
+++ b/M2Crypto/SMIME.py
@@ -1,9 +1,11 @@
+from __future__ import absolute_import
+
"""M2Crypto wrapper for OpenSSL S/MIME API.
Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved."""
-import BIO, EVP, X509, Err, util
-import m2
+from . import BIO, EVP, X509, Err, util
+from . import m2
PKCS7_TEXT = m2.PKCS7_TEXT
PKCS7_NOCERTS = m2.PKCS7_NOCERTS
diff --git a/M2Crypto/SSL/Connection.py b/M2Crypto/SSL/Connection.py
index f1eb8c3..5fc0bed 100644
--- a/M2Crypto/SSL/Connection.py
+++ b/M2Crypto/SSL/Connection.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
"""SSL Connection aka socket
Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved.
@@ -16,14 +18,14 @@ __all__ = ['Connection',
import socket
# M2Crypto
-import Checker
+from . import Checker
-import timeout
+from . import timeout
-from Cipher import Cipher, Cipher_Stack
+from .Cipher import Cipher, Cipher_Stack
from M2Crypto import X509, m2
from M2Crypto.SSL import SSLError
-from Session import Session
+from .Session import Session
#SSLError = getattr(__import__('M2Crypto.SSL', globals(), locals(),
# 'SSLError'), 'SSLError')
diff --git a/M2Crypto/SSL/Context.py b/M2Crypto/SSL/Context.py
index 2dc0aea..d11d656 100644
--- a/M2Crypto/SSL/Context.py
+++ b/M2Crypto/SSL/Context.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
"""SSL Context
Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved."""
@@ -6,7 +8,7 @@ __all__ = ['map', 'Context']
# M2Crypto
-import cb
+from . import cb
import sys
from M2Crypto import BIO, Err, RSA, X509, m2, util
diff --git a/M2Crypto/SSL/SSLServer.py b/M2Crypto/SSL/SSLServer.py
index 4d8132e..e5c408a 100644
--- a/M2Crypto/SSL/SSLServer.py
+++ b/M2Crypto/SSL/SSLServer.py
@@ -1,4 +1,4 @@
-from __future__ import print_function
+from __future__ import absolute_import, print_function
"""SSLServer
@@ -10,7 +10,7 @@ __all__ = ['SSLServer', 'ForkingSSLServer', 'ThreadingSSLServer']
import socket, SocketServer
# M2Crypto
-from Connection import Connection
+from .Connection import Connection
from M2Crypto.SSL import SSLError
from M2Crypto import m2
diff --git a/M2Crypto/SSL/__init__.py b/M2Crypto/SSL/__init__.py
index 00d4e54..abc7441 100644
--- a/M2Crypto/SSL/__init__.py
+++ b/M2Crypto/SSL/__init__.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
"""M2Crypto SSL services.
Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved."""
@@ -12,12 +14,12 @@ class SSLTimeoutError(SSLError, socket.timeout): pass
m2.ssl_init(SSLError, SSLTimeoutError)
# M2Crypto.SSL
-from Cipher import Cipher, Cipher_Stack
-from Context import Context
-from Connection import Connection
-from SSLServer import SSLServer, ForkingSSLServer, ThreadingSSLServer
-from ssl_dispatcher import ssl_dispatcher
-from timeout import timeout
+from .Cipher import Cipher, Cipher_Stack
+from .Context import Context
+from .Connection import Connection
+from .SSLServer import SSLServer, ForkingSSLServer, ThreadingSSLServer
+from .ssl_dispatcher import ssl_dispatcher
+from .timeout import timeout
verify_none = m2.SSL_VERIFY_NONE
verify_peer = m2.SSL_VERIFY_PEER
diff --git a/M2Crypto/SSL/cb.py b/M2Crypto/SSL/cb.py
index 60f9dbd..d7204fd 100644
--- a/M2Crypto/SSL/cb.py
+++ b/M2Crypto/SSL/cb.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
"""SSL callbacks
Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved."""
@@ -9,7 +11,6 @@ __all__ = ['unknown_issuer', 'ssl_verify_callback_stub', 'ssl_verify_callback',
import sys
# M2Crypto
-import Context
from M2Crypto import m2
def ssl_verify_callback_stub(ssl_ctx_ptr, x509_ptr, errnum, errdepth, ok):
@@ -25,6 +26,7 @@ unknown_issuer = [
def ssl_verify_callback(ssl_ctx_ptr, x509_ptr, errnum, errdepth, ok):
# Deprecated
+ from . import Context
ssl_ctx = Context.map()[long(ssl_ctx_ptr)]
if errnum in unknown_issuer:
if ssl_ctx.get_allow_unknown_ca():
diff --git a/M2Crypto/SSL/ssl_dispatcher.py b/M2Crypto/SSL/ssl_dispatcher.py
index 1e8c875..4c66cdb 100644
--- a/M2Crypto/SSL/ssl_dispatcher.py
+++ b/M2Crypto/SSL/ssl_dispatcher.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
"""SSL dispatcher
Copyright (c) 1999-2002 Ng Pheng Siong. All rights reserved."""
@@ -8,7 +10,7 @@ __all__ = ['ssl_dispatcher']
import asyncore, socket
# M2Crypto
-from Connection import Connection
+from .Connection import Connection
from M2Crypto import Err, m2
diff --git a/M2Crypto/X509.py b/M2Crypto/X509.py
index 62aa4ed..87566d5 100644
--- a/M2Crypto/X509.py
+++ b/M2Crypto/X509.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
"""M2Crypto wrapper for OpenSSL X509 API.
Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved.
@@ -9,6 +11,8 @@ Author: Heikki Toivonen
# M2Crypto
import binascii
+from M2Crypto import ASN1, BIO, Err, EVP, util
+from . import m2
import m2
diff --git a/M2Crypto/__init__.py b/M2Crypto/__init__.py
index 4486918..2e7a732 100644
--- a/M2Crypto/__init__.py
+++ b/M2Crypto/__init__.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
"""
M2Crypto is the most complete Python wrapper for OpenSSL featuring RSA, DSA,
DH, EC, HMACs, message digests, symmetric ciphers (including AES); SSL
@@ -21,37 +23,35 @@ __version__ = '0.23.0'
version = __version__
version_info = StrictVersion(__version__).version
-import _m2crypto
-import m2
-import ASN1
-import AuthCookie
-import BIO
-import BN
-import Rand
-import DH
-import DSA
+from . import _m2crypto
+from . import m2
+from . import ASN1
+from . import AuthCookie
+from . import BIO
+from . import BN
+from . import Rand
+from . import DH
+from . import DSA
if m2.OPENSSL_VERSION_NUMBER >= 0x90800F and m2.OPENSSL_NO_EC == 0:
- import EC
-import Err
-import Engine
-import EVP
-import RSA
-import RC4
-import SMIME
-import SSL
-import X509
-import PGP
-import m2urllib
+ from . import EC
+from . import Err
+from . import Engine
+from . import EVP
+from . import RSA
+from . import RC4
+from . import SMIME
+from . import SSL
+from . import X509
+from . import PGP
+from . import m2urllib
# Backwards compatibility.
urllib2 = m2urllib
-import m2urllib2
-
-import ftpslib
-import httpslib
-import m2xmlrpclib
-import threading
-import util
+from . import ftpslib
+from . import httpslib
+from . import m2xmlrpclib
+from . import threading
+from . import util
encrypt = 1
decrypt = 0
diff --git a/M2Crypto/callback.py b/M2Crypto/callback.py
index 46613ca..edf16f0 100644
--- a/M2Crypto/callback.py
+++ b/M2Crypto/callback.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
"""Deprecated, use the util module instead.
Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved."""
@@ -6,4 +8,4 @@ import warnings
warnings.warn('Use the util module instead', DeprecationWarning)
-from util import genparam_callback, passphrase_callback
+from .util import genparam_callback, passphrase_callback
diff --git a/M2Crypto/ftpslib.py b/M2Crypto/ftpslib.py
index 9dfaf59..c1def37 100644
--- a/M2Crypto/ftpslib.py
+++ b/M2Crypto/ftpslib.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
"""M2Crypto client-side FTP/TLS.
This implementation complies with draft-murray-auth-ftp-ssl-07.txt.
@@ -38,7 +40,7 @@ import socket # noqa
import time # noqa
# M2Crypto
-import SSL
+from . import SSL
DEFAULT_PROTOCOL = 'sslv23'
diff --git a/M2Crypto/httpslib.py b/M2Crypto/httpslib.py
index 2984c40..777e96c 100644
--- a/M2Crypto/httpslib.py
+++ b/M2Crypto/httpslib.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
"""M2Crypto support for Python's httplib.
Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved."""
@@ -8,8 +10,8 @@ from urlparse import urlsplit, urlunsplit
import base64
from httplib import *
-from httplib import HTTPS_PORT # This is not imported with just '*'
-import SSL
+from httplib import HTTPS_PORT # This is not imported with just '*'
+from . import SSL
class HTTPSConnection(HTTPConnection):
diff --git a/M2Crypto/m2.py b/M2Crypto/m2.py
index 7dac083..cfe1c98 100644
--- a/M2Crypto/m2.py
+++ b/M2Crypto/m2.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
"""M2Crypto low level OpenSSL wrapper functions.
m2 is the low level wrapper for OpenSSL functions. Typically you would not
@@ -25,5 +27,5 @@ Portions created by Open Source Applications Foundation (OSAF) are
Copyright (C) 2004 OSAF. All Rights Reserved.
"""
-from _m2crypto import *
+from ._m2crypto import *
lib_init()
diff --git a/M2Crypto/m2urllib.py b/M2Crypto/m2urllib.py
index 8e1de49..a1ed7f8 100644
--- a/M2Crypto/m2urllib.py
+++ b/M2Crypto/m2urllib.py
@@ -1,4 +1,4 @@
-from __future__ import print_function
+from __future__ import absolute_import, print_function
"""M2Crypto enhancement to Python's urllib for handling
'https' url's.
@@ -8,8 +8,8 @@ Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved."""
import string, sys, urllib
from urllib import *
-import SSL
-import httpslib
+from . import SSL
+from . import httpslib
DEFAULT_PROTOCOL = 'sslv23'
diff --git a/M2Crypto/m2urllib2.py b/M2Crypto/m2urllib2.py
index 4ccfaf5..5bd1090 100644
--- a/M2Crypto/m2urllib2.py
+++ b/M2Crypto/m2urllib2.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
"""
M2Crypto enhancement to Python's urllib2 for handling
'https' url's.
@@ -14,7 +16,15 @@ Summary of changes:
import socket
import urlparse
-import SSL
+from . import SSL
+from . import httpslib
+
+
+class _closing_fileobject(socket._fileobject):
+ '''socket._fileobject that propagates self.close() to the socket.
+
+ Python 2.5 provides this as socket._fileobject(sock, close=True).
+ '''
import httpslib
from urllib2 import * # noqa
diff --git a/M2Crypto/m2xmlrpclib.py b/M2Crypto/m2xmlrpclib.py
index 326d1bd..7090a5d 100644
--- a/M2Crypto/m2xmlrpclib.py
+++ b/M2Crypto/m2xmlrpclib.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
"""M2Crypto enhancement to xmlrpclib.
Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved."""
@@ -6,7 +8,7 @@ import base64, string, sys
from xmlrpclib import *
import M2Crypto
-import SSL, httpslib, m2urllib
+from . import SSL, httpslib, m2urllib
__version__ = M2Crypto.version
diff --git a/M2Crypto/threading.py b/M2Crypto/threading.py
index d313f3e..77c1b5f 100644
--- a/M2Crypto/threading.py
+++ b/M2Crypto/threading.py
@@ -1,10 +1,12 @@
+from __future__ import absolute_import
+
"""
M2Crypto threading support, required for multithreaded applications.
Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved."""
# M2Crypto
-import m2
+from . import m2
def init():
"""
diff --git a/M2Crypto/util.py b/M2Crypto/util.py
index c577034..99a0497 100644
--- a/M2Crypto/util.py
+++ b/M2Crypto/util.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
"""
M2Crypto utility routines.
@@ -8,7 +10,7 @@
"""
import sys
-import m2
+from . import m2
# Python 2 has int() and long().
# Python 3 and higher only has int().