From: Wouter Wijngaards Date: Mon, 12 Jan 2015 15:20:20 +0000 (+0000) Subject: - Fix pyunbound ord call, portable for python 2 and 3. X-Git-Tag: release-1.5.2rc1~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=03d1afc32a21142ef7b45721274dd8aab9cee3cf;p=thirdparty%2Funbound.git - Fix pyunbound ord call, portable for python 2 and 3. git-svn-id: file:///svn/unbound/trunk@3313 be551aaa-1e26-0410-a405-d3ace91eadb9 --- 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"