From ce804f486aae0b57fb6cb221d6bd7dee3060a904 Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Tue, 18 Nov 2008 14:32:45 +0000 Subject: [PATCH] Python 2.6 fixes --- pybindgen/cppclass.py | 4 +++- pybindgen/typehandlers/ctypeparser/__init__.py | 5 +++-- pybindgen/typehandlers/ctypeparser/tokenizer.py | 5 +++-- pybindgen/wrapper_registry.py | 4 ++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pybindgen/cppclass.py b/pybindgen/cppclass.py index 3ff3fdd..6fc393a 100644 --- a/pybindgen/cppclass.py +++ b/pybindgen/cppclass.py @@ -21,7 +21,9 @@ from pytypeobject import PyTypeObject, PyNumberMethods import settings import utils -if 'set' not in dir(__builtins__): +try: + set +except AttributeError: from sets import Set as set diff --git a/pybindgen/typehandlers/ctypeparser/__init__.py b/pybindgen/typehandlers/ctypeparser/__init__.py index df654d8..aeb9294 100644 --- a/pybindgen/typehandlers/ctypeparser/__init__.py +++ b/pybindgen/typehandlers/ctypeparser/__init__.py @@ -3,8 +3,9 @@ import tokenizer MODIFIERS = ['const', 'volatile'] # XXX: are there others? -if 'set' not in dir(__builtins__): - # Nominal support for Python 2.3. +try: + set +except AttributeError: from sets import Set as set diff --git a/pybindgen/typehandlers/ctypeparser/tokenizer.py b/pybindgen/typehandlers/ctypeparser/tokenizer.py index 461d91c..afcdd1c 100644 --- a/pybindgen/typehandlers/ctypeparser/tokenizer.py +++ b/pybindgen/typehandlers/ctypeparser/tokenizer.py @@ -29,8 +29,9 @@ import sys DEBUG = False -if 'set' not in dir(__builtins__): - # Nominal support for Python 2.3. +try: + set +except AttributeError: from sets import Set as set diff --git a/pybindgen/wrapper_registry.py b/pybindgen/wrapper_registry.py index 1f65d37..992ffa7 100644 --- a/pybindgen/wrapper_registry.py +++ b/pybindgen/wrapper_registry.py @@ -30,7 +30,7 @@ class WrapperRegistry(object): raise NotImplementedError -class NullWrapperRegistry(object): +class NullWrapperRegistry(WrapperRegistry): """ A 'null' wrapper registry class. It produces no code, and does not guarantee that more than one wrapper cannot be created for @@ -56,7 +56,7 @@ class NullWrapperRegistry(object): pass -class StdMapWrapperRegistry(object): +class StdMapWrapperRegistry(WrapperRegistry): """ A wrapper registry that uses std::map as implementation. Do not use this if generating pure C wrapping code, else the code will