diff --git a/doc/Changelog b/doc/Changelog index b2465fead..b5208d7ff 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,5 +1,6 @@ 12 January 2015: Wouter - Cast sun_len sizeof to socklen_t. + - Fix pyunbound ord call, portable for python 2 and 3. 7 January 2015: Wouter - Fix warnings in pythonmod changes. diff --git a/libunbound/python/libunbound.i b/libunbound/python/libunbound.i index 313c74862..633cc0018 100644 --- a/libunbound/python/libunbound.i +++ b/libunbound/python/libunbound.i @@ -44,6 +44,10 @@ %pythoncode %{ import encodings.idna + try: + import builtins + except ImportError: + import __builtin__ as builtins # Ensure compatibility with older python versions if 'bytes' not in vars(): @@ -52,7 +56,7 @@ def ord(s): if isinstance(s, int): return s - return __builtins__.ord(s) + return builtins.ord(s) %} //%include "doc.i"