From 03d1afc32a21142ef7b45721274dd8aab9cee3cf Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Mon, 12 Jan 2015 15:20:20 +0000 Subject: [PATCH] - Fix pyunbound ord call, portable for python 2 and 3. git-svn-id: file:///svn/unbound/trunk@3313 be551aaa-1e26-0410-a405-d3ace91eadb9 --- doc/Changelog | 1 + libunbound/python/libunbound.i | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) 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"