From: David Coles Date: Fri, 8 Apr 2011 23:49:30 +0000 (-0700) Subject: Use absolute imports in xcbgen for Python 3 compatibility X-Git-Url: http://git.demorecorder.com/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f877a6f34c16bc73bccc18073b3512318d49e92c;p=free-sw%2Fxcb%2Fproto Use absolute imports in xcbgen for Python 3 compatibility Python 3 has stricter syntax for relative imports. Use absolute imports to ensure compatibility with all versions of Python. Also break cyclical module import between state.py and matcher.py by deferring import. Signed-off-by: David Coles Signed-off-by: Julien Danjou --- diff --git a/xcbgen/matcher.py b/xcbgen/matcher.py index e7958fa..6e45b23 100644 --- a/xcbgen/matcher.py +++ b/xcbgen/matcher.py @@ -9,14 +9,15 @@ we do not create a new type object, we just record the existing one under a new from os.path import join from xml.etree.cElementTree import parse -import state -from xtypes import * +from xcbgen.xtypes import * def import_(node, module, namespace): ''' For imports, we load the file, create a new namespace object, execute recursively, then record the import (for header files, etc.) ''' + # To avoid circular import error + from xcbgen import state new_file = join(namespace.dir, '%s.xml' % node.text) new_root = parse(new_file).getroot() new_namespace = state.Namespace(new_file) diff --git a/xcbgen/state.py b/xcbgen/state.py index 51efc94..ae3d2d4 100644 --- a/xcbgen/state.py +++ b/xcbgen/state.py @@ -4,9 +4,9 @@ This module contains the namespace class and the singleton module class. from os.path import dirname, basename from xml.etree.cElementTree import parse -import matcher -from error import * -from xtypes import * +from xcbgen import matcher +from xcbgen.error import * +from xcbgen.xtypes import * import __main__ diff --git a/xcbgen/xtypes.py b/xcbgen/xtypes.py index 1a6c7ce..14c318a 100644 --- a/xcbgen/xtypes.py +++ b/xcbgen/xtypes.py @@ -1,7 +1,7 @@ ''' This module contains the classes which represent XCB data types. ''' -from expr import Field, Expression +from xcbgen.expr import Field, Expression import __main__ class Type(object):