Assorted changes (mostly sytlistic) to reduce differences with the master branch.
authorW. Trevor King <wking@drexel.edu>
Wed, 9 Mar 2011 23:50:53 +0000 (18:50 -0500)
committerW. Trevor King <wking@drexel.edu>
Wed, 9 Mar 2011 23:50:53 +0000 (18:50 -0500)
Cython/Compiler/AnalysedTreeTransforms.py
Cython/Compiler/Buffer.py
Cython/Compiler/CythonScope.py
Cython/Compiler/ExprNodes.py
Cython/Compiler/ModuleNode.py
Cython/Compiler/Nodes.py
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/PyrexTypes.py
Cython/Compiler/Symtab.py

index f2ddfd816a4b88b3e4e726a4c2d1de2da6c92190..318561261b306d0dbfba782fc60702e51c1cf9ca 100644 (file)
@@ -39,7 +39,9 @@ class AutoTestDictTransform(ScopeTrackingTransform):
         self.testspos = node.pos
 
         test_dict_entry = node.scope.declare_var(
-            name = EncodedString(u'__test__'), c_visibility = 'public', type = py_object_type, pos = pos)
+            name = EncodedString(u'__test__'),
+            c_visibility = 'public',
+            type = py_object_type, pos = pos)
         create_test_dict_assignment = SingleAssignmentNode(pos,
             lhs=NameNode(pos, name=EncodedString(u'__test__'),
                          entry=test_dict_entry),
index 9e47765be273b6877f5aeec90e2e9455f4e4488e..d7129fabb422e7141a9e01d347621e6052538cb0 100644 (file)
@@ -70,16 +70,16 @@ class IntroduceBufferAuxiliaryVars(CythonTransform):
 
             # Declare auxiliary vars
             cname = scope.mangle(Naming.bufstruct_prefix, name)
-            bufinfo = scope.declare_var(
-                name="$%s" % cname, cname=cname, type=PyrexTypes.c_py_buffer_type, pos=node.pos)
+            bufinfo = scope.declare_var(name="$%s" % cname, cname=cname,
+                                        type=PyrexTypes.c_py_buffer_type, pos=node.pos)
             if entry.is_arg:
                 bufinfo.used = True # otherwise, NameNode will mark whether it is used
 
             def var(prefix, idx, initval):
                 cname = scope.mangle(prefix, "%d_%s" % (idx, name))
-                result = scope.declare_var(
-                    name="$%s" % cname, cname=cname, type=PyrexTypes.c_py_ssize_t_type, is_cdef=True,
-                    pos=node.pos)
+                result = scope.declare_var(name="$%s" % cname, cname=cname,
+                                           type=PyrexTypes.c_py_ssize_t_type,
+                                           is_cdef=True, pos=node.pos)
 
                 result.init = initval
                 if entry.is_arg:
index d70b3277083a6335e616f4cf8bf6b4dad1662cea..4a2f9984e082f60ad6ae84f890aeb2c975c2a8b9 100644 (file)
@@ -10,8 +10,11 @@ class CythonScope(ModuleScope):
         ModuleScope.__init__(self, u'cython', None, context)
         self.pxd_file_loaded = True
 
-        self.shape_entry = self.declare_cfunction(
-            name = 'shape', cname = '<error>', type = shape_func_type, defining = 1)
+        self.shape_entry = self.declare_cfunction('shape',
+                                                  type=shape_func_type,
+                                                  pos=None,
+                                                  defining = 1,
+                                                  cname='<error>')
 
     def lookup_type(self, name):
         # This function should go away when types are all first-level objects.
@@ -29,13 +32,19 @@ def create_utility_scope(context):
     utility_scope = ModuleScope(u'utility', None, context)
 
     # These are used to optimize isinstance in FinalOptimizePhase
-    type_object = utility_scope.declare_typedef(
-        name = 'PyTypeObject', cname = 'PyTypeObject', base_type = c_void_type, pos = None)
+    type_object = utility_scope.declare_typedef('PyTypeObject',
+                                                base_type = c_void_type,
+                                                pos = None,
+                                                cname = 'PyTypeObject')
     type_object.is_void = True
 
     func_type = CFuncType(
         c_bint_type, [CFuncTypeArg("o", py_object_type, None),
                       CFuncTypeArg("t", c_ptr_type(type_object), None)])
-    utility_scope.declare_cfunction(name = 'PyObject_TypeCheck', cname = 'PyObject_TypeCheck', type = func_type, defining = 1)
+    utility_scope.declare_cfunction(
+                'PyObject_TypeCheck',
+                type = func_type,
+                defining = 1,
+                cname = 'PyObject_TypeCheck')
 
     return utility_scope
index 4a302abc4197e368ca59c43f5a4d1c8c6c660d4c..da7a76ac5cf3fdf73c05a58077102a9c0d1e8008 100755 (executable)
@@ -3492,7 +3492,9 @@ class AttributeNode(ExprNode):
             if entry and entry.is_cmethod:
                 # Create a temporary entry describing the C method
                 # as an ordinary function.
-                ubcm_entry = Symtab.Entry(name = entry.name, cname = '%s->%s' % (type.vtabptr_cname, entry.cname), type = entry.type)
+                ubcm_entry = Symtab.Entry(entry.name,
+                    cname = '%s->%s' % (type.vtabptr_cname, entry.cname),
+                    type = entry.type)
                 ubcm_entry.is_cfunction = 1
                 ubcm_entry.func_cname = entry.func_cname
                 ubcm_entry.is_unbound_cmethod = 1
index 80312ab2689652d51c676c5bd38ce7d06c06214a..7ccff3ed3f03214e4a9562d46ea44aa70ce0a43c 100644 (file)
@@ -98,8 +98,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
     def generate_h_code(self, env, options, result):
         def h_entries(entries, pxd = 0):
             return [entry for entry in entries
-                    if entry.c_visibility == 'public'
-                    or pxd and entry.defined_in_pxd]
+                if entry.c_visibility == 'public' or pxd and entry.defined_in_pxd]
         h_types = h_entries(env.type_entries)
         h_vars = h_entries(env.var_entries)
         h_funcs = h_entries(env.cfunc_entries)
index 03d4c352d9edacf74ecd753607718a7361cb8804..f59986cf6a2cb1c23e909363ebd54794ac2e17f8 100644 (file)
@@ -569,8 +569,12 @@ class CFuncDeclaratorNode(CDeclaratorNode):
                     name = arg.name, type = arg.type, allow_pyobject = 1,
                     pos = arg.pos)
             struct_cname = env.mangle(Naming.opt_arg_prefix, self.base.name)
-            self.op_args_struct = env.global_scope().declare_struct_or_union(
-                name = struct_cname, cname = struct_cname, kind = 'struct', scope = scope, pos = self.pos)
+            self.op_args_struct = env.global_scope().declare_struct_or_union(name = struct_cname,
+                                        kind = 'struct',
+                                        scope = scope,
+                                        typedef_flag = 0,
+                                        pos = self.pos,
+                                        cname = struct_cname)
             self.op_args_struct.defined_in_pxd = 1
             self.op_args_struct.used = 1
 
@@ -936,7 +940,8 @@ class CVarDefNode(StatNode):
         # If the field is an external typedef, we cannot be sure about the type,
         # so do conversion ourself rather than rely on the CPython mechanism (through
         # a property; made in AnalyseDeclarationsTransform).
-        if dest_scope.is_c_class_scope and self.c_visibility == 'public':
+        if (dest_scope.is_c_class_scope
+            and self.visibility in ('public', 'readonly')):
             need_property = True
         else:
             need_property = False
@@ -1651,9 +1656,15 @@ class CFuncDefNode(FuncDefNode):
             formal_arg.cname = type_arg.cname
             if type_arg.type.is_buffer and 'inline' in self.modifiers:
                 warning(formal_arg.pos, "Buffer unpacking not optimized away.", 1)
+        name = name_declarator.name
+        cname = name_declarator.cname
         self.entry = env.declare_cfunction(
-            name = name_declarator.name, cname = name_declarator.cname, c_visibility = self.c_visibility, visibility = self.visibility, overridable = self.overridable, api = self.api, type = type, defining = self.body is not None,
-            modifiers = self.modifiers, pos = self.pos)
+            name = name, type = type, pos = self.pos,
+            cname = cname, visibility = self.visibility,
+            c_visibility = self.c_visibility,
+            overridable = self.overridable,
+            defining = self.body is not None,
+            api = self.api, modifiers = self.modifiers)
         self.entry.inline_func_in_pxd = self.inline_in_pxd
         self.return_type = type.return_type
         if self.return_type.is_array and self.c_visibility != 'extern':
@@ -1680,7 +1691,7 @@ class CFuncDefNode(FuncDefNode):
             self.py_func.analyse_declarations(env)
             self.entry.as_variable = self.py_func.entry
             # Reset scope entry the above cfunction
-            env.entries[self.entry.name] = self.entry
+            env.entries[name] = self.entry
             if not env.is_module_scope or Options.lookup_module_cpdef:
                 self.override = OverrideCheckNode(self.pos, py_func = self.py_func)
                 self.body = StatListNode(self.pos, stats=[self.override, self.body])
@@ -3246,17 +3257,20 @@ class CClassDefNode(ClassDefNode):
                 warning(self.pos, "%s already a builtin Cython type" % self.class_name, 1)
 
         self.entry = home_scope.declare_c_class(
-            name = self.class_name, c_visibility = self.c_visibility, visibility = self.visibility, api = self.api,
-            objstruct_cname = self.objstruct_name,
-            base_type = self.base_type,
+            name = self.class_name,
+            pos = self.pos,
             defining = has_body and self.in_pxd,
             implementing = has_body and not self.in_pxd,
             module_name = self.module_name,
+            base_type = self.base_type,
+            objstruct_cname = self.objstruct_name,
             typeobj_cname = self.typeobj_name,
+            c_visibility = self.c_visibility,
+            visibility = self.visibility,
             typedef_flag = self.typedef_flag,
+            api = self.api,
             buffer_defaults = buffer_defaults,
-            shadow = self.shadow,
-            pos = self.pos)
+            shadow = self.shadow)
         if self.shadow:
             home_scope.lookup(self.class_name).as_variable = self.entry
         if home_scope is not env and self.c_visibility == 'extern':
index 6116419cbc24f756887fab26f6e297f829bd3959..e121887750dc91d2ad981e54eb079177445b1517 100644 (file)
@@ -1485,8 +1485,8 @@ class CreateClosureClasses(CythonTransform):
 
         as_name = '%s_%s' % (target_module_scope.next_id(Naming.closure_class_prefix), node.entry.cname)
 
-        entry = target_module_scope.declare_c_class(
-            name = as_name, defining = True, implementing = True, pos = node.pos)
+        entry = target_module_scope.declare_c_class(name = as_name,
+            pos = node.pos, defining = True, implementing = True)
         func_scope.scope_class = entry
         class_scope = entry.type.scope
         class_scope.is_internal = True
@@ -1494,13 +1494,18 @@ class CreateClosureClasses(CythonTransform):
 
         if from_closure:
             assert cscope.is_closure_scope
-            class_scope.declare_var(
-                name=Naming.outer_scope_cname, cname=Naming.outer_scope_cname, type=cscope.scope_class.type, is_cdef=True,
-                pos=node.pos)
+            class_scope.declare_var(pos=node.pos,
+                                    name=Naming.outer_scope_cname,
+                                    cname=Naming.outer_scope_cname,
+                                    type=cscope.scope_class.type,
+                                    is_cdef=True)
             node.needs_outer_scope = True
         for name, entry in in_closure:
-            class_scope.declare_var(
-                name=entry.name, cname=entry.cname, type=entry.type, is_cdef=True, pos=entry.pos)
+            class_scope.declare_var(pos=entry.pos,
+                                    name=entry.name,
+                                    cname=entry.cname,
+                                    type=entry.type,
+                                    is_cdef=True)
         node.needs_closure = True
         # Do it here because other classes are already checked
         target_module_scope.check_c_class(func_scope.scope_class)
@@ -1737,6 +1742,7 @@ class DebugTransform(CythonTransform):
             self.nested_funcdefs.append(node)
             return node
 
+        # node.entry.visibility = 'extern'
         if node.py_func is None:
             pf_cname = ''
         else:
index d7bf22b09ace1a016432938689d3cc63e0857228..d9093f3c4e50b7df2e322b0515464ff3cf4a3901 100755 (executable)
@@ -2013,7 +2013,7 @@ class CStructOrUnionType(CType):
                     self.to_py_function = None
                     self._convert_code = False
                     return False
-            forward_decl = self.entry.c_visibility != 'extern'
+            forward_decl = (self.entry.c_visibility != 'extern')
             self._convert_code = StructUtilityCode(self, forward_decl)
         
         env.use_utility_code(self._convert_code)
index 01657fe429b381390be1c45a1fc7799859374815..2710d6b487375d5f4e07ea9cc5a38fec8558a8e4 100644 (file)
@@ -58,9 +58,12 @@ class BufferAux(object):
 class Entry(object):
     # A symbol table entry in a Scope or ModuleNamespace.
     #
+    # name             string     Python name of entity
+    # cname            string     C name of entity
     # type             PyrexType  Type of entity
     # doc              string     Doc string
     # init             string     Initial value
+    # visibility       'private' or 'public' or 'extern'
     # is_builtin       boolean    Is an entry in the Python builtins dict
     # is_cglobal       boolean    Is a C global variable
     # is_pyglobal      boolean    Is a Python module-level variable
@@ -112,6 +115,7 @@ class Entry(object):
     # is_special       boolean    Is a special method or property accessor
     #                               of an extension type
     # defined_in_pxd   boolean    Is defined in a .pxd file (not just declared)
+    # api              boolean    Generate C API for C class or function
     # utility_code     string     Utility code needed when this entry is used
     #
     # buffer_aux       BufferAux or None  Extra information needed for buffer variables
@@ -195,7 +199,6 @@ class Entry(object):
     def all_alternatives(self):
         return [self] + self.overloaded_alternatives
 
-
 class Scope(object):
     # name              string             Unqualified name
     # outer_scope       Scope or None      Enclosing scope
@@ -335,8 +338,7 @@ class Scope(object):
         # declared.
         if type.is_buffer and not isinstance(self, LocalScope):
             error(pos, ERR_BUF_LOCALONLY)
-        if (not self.in_cinclude and
-            cname and re.match("^_[_A-Z]+$", cname)):
+        if not self.in_cinclude and cname and re.match("^_[_A-Z]+$", cname):
             # See http://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html#Reserved-Names
             warning(pos, "'%s' is a reserved name in C." % cname, -1)
         entries = self.entries
@@ -350,12 +352,11 @@ class Scope(object):
         if name:
             entry.qualified_name = self.qualify_name(name)
 #            if name in entries and self.is_cpp():
-#                entries[name].overloaded_alternatives.append(
-#                    entry)
+#                entries[name].overloaded_alternatives.append(entry)
 #            else:
 #                entries[name] = entry
             if not shadow:
-                 entries[name] = entry
+                entries[name] = entry
         entry.scope = self
         return entry
 
@@ -368,8 +369,7 @@ class Scope(object):
             if self.in_cinclude or c_visibility == 'public':
                 cname = name
             else:
-                cname = self.mangle(
-                    Naming.enum_prefix, name)
+                cname = self.mangle(Naming.enum_prefix, name)
         entry = self.declare(name = name, cname = cname, namespace = namespace, c_visibility = c_visibility, visibility = visibility, overridable = overridable, api = api, type = type, pos = pos)
         entry.is_const = 1
         entry.value_node = value
@@ -393,12 +393,10 @@ class Scope(object):
             if self.in_cinclude or c_visibility == 'public':
                 cname = name
             else:
-                cname = self.mangle(
-                    Naming.type_prefix, name)
+                cname = self.mangle(Naming.type_prefix, name)
         try:
-            type = PyrexTypes.create_typedef_type(
-                name, base_type, cname,
-                c_visibility == 'extern')
+            type = PyrexTypes.create_typedef_type(name, base_type, cname,
+                                                  c_visibility == 'extern')
         except ValueError, e:
             error(pos, e.args[0])
             type = PyrexTypes.error_type
@@ -414,13 +412,11 @@ class Scope(object):
             if self.in_cinclude or c_visibility == 'public':
                 cname = name
             else:
-                cname = self.mangle(
-                    Naming.type_prefix, name)
+                cname = self.mangle(Naming.type_prefix, name)
         entry = self.lookup_here(name)
         if not entry:
             type = PyrexTypes.CStructOrUnionType(
-                name, kind, scope, typedef_flag, cname,
-                packed)
+                name, kind, scope, typedef_flag, cname, packed)
             entry = self.declare_type(
                 name = name, cname = cname, namespace = namespace, c_visibility = c_visibility, visibility = visibility, overridable = overridable, api = api, type = type,
                 defining = scope is not None, pos = pos)
@@ -431,9 +427,7 @@ class Scope(object):
                     and entry.type.kind == kind):
                 warning(pos, "'%s' redeclared  " % name, 0)
             elif scope and entry.type.scope:
-                warning(
-                    pos, "'%s' already defined  (ignoring second definition)" %
-                    name, 0)
+                warning(pos, "'%s' already defined  (ignoring second definition)" % name, 0)
             else:
                 self.check_previous_typedef_flag(entry, typedef_flag, pos)
                 self.check_previous_visibility(entry, name = name, cname = cname, namespace = namespace, c_visibility = c_visibility, visibility = visibility, overridable = overridable, api = api, pos = pos)
@@ -454,8 +448,7 @@ class Scope(object):
         entry = self.lookup_here(name)
         if not entry:
             type = PyrexTypes.CppClassType(
-                name, scope, cname, base_classes,
-                templates = templates)
+                name, scope, cname, base_classes, templates = templates)
             entry = self.declare_type(
                 name = name, cname = cname, namespace = namespace, c_visibility = c_visibility, visibility = visibility, overridable = overridable, api = api, type = type,
                 defining = scope is not None, pos = pos)
@@ -464,9 +457,7 @@ class Scope(object):
                 error(pos, "'%s' redeclared " % name)
                 return None
             elif scope and entry.type.scope:
-                warning(
-                    pos, "'%s' already defined  (ignoring second definition)" %
-                    name, 0)
+                warning(pos, "'%s' already defined  (ignoring second definition)" % name, 0)
             else:
                 if scope:
                     entry.type.scope = scope
@@ -474,9 +465,7 @@ class Scope(object):
         if templates is not None:
             c_visibility = 'extern'
             for T in templates:
-                name = T.name
-                cname = T.name
-                template_entry = entry.type.scope.declare(name = name, cname = cname, namespace = namespace, c_visibility = c_visibility, visibility = visibility, overridable = overridable, api = api, type=T)
+                template_entry = entry.type.scope.declare(name = T.name, cname = T.name, namespace = namespace, c_visibility = c_visibility, visibility = visibility, overridable = overridable, api = api, type=T)
                 template_entry.is_type = 1
 
         def declare_inherited_attributes(entry, base_classes):
@@ -522,10 +511,8 @@ class Scope(object):
                 if self.in_cinclude or c_visibility == 'public':
                     cname = name
                 else:
-                    cname = self.mangle(
-                        Naming.type_prefix, name)
-            type = PyrexTypes.CEnumType(
-                name, cname, typedef_flag)
+                    cname = self.mangle(Naming.type_prefix, name)
+            type = PyrexTypes.CEnumType(name, cname, typedef_flag)
         else:
             type = PyrexTypes.c_anon_enum_type
         entry = self.declare_type(name = name, cname = cname, namespace = namespace, c_visibility = c_visibility, visibility = visibility, overridable = overridable, api = api, type = type, pos = pos)
@@ -539,16 +526,14 @@ class Scope(object):
             if c_visibility != 'private':
                 cname = name
             else:
-                cname = self.mangle(
-                    Naming.var_prefix, name)
+                cname = self.mangle(Naming.var_prefix, name)
         if type.is_cpp_class and c_visibility != 'extern':
             constructor = type.scope.lookup(u'<init>')
             if constructor is not None and PyrexTypes.best_match([], constructor.all_alternatives()) is None:
                 error(pos, "C++ class must have a default constructor to be stack allocated")
         entry = self.declare(name = name, cname = cname, namespace = namespace, c_visibility = c_visibility, visibility = visibility, overridable = overridable, api = api, type = type, pos = pos)
         entry.is_variable = 1
-        self.control_flow.set_state(
-            (), (name, 'initialized'), False)
+        self.control_flow.set_state((), (name, 'initialized'), False)
         return entry
 
     def declare_builtin(self, name, cname = None, namespace = None, c_visibility = 'private', visibility = 'public', overridable = 0, api = 0, pos = None):
@@ -611,8 +596,7 @@ class Scope(object):
             if api or c_visibility != 'private':
                 cname = name
             else:
-                cname = self.mangle(
-                    Naming.func_prefix, name)
+                cname = self.mangle(Naming.func_prefix, name)
         entry = self.lookup_here(name)
         if entry:
             vis_diff = self._check_previous_visibility(entry, c_visibility = c_visibility, visibility = visibility)
@@ -628,8 +612,7 @@ class Scope(object):
                         # if all alternatives have different cnames,
                         # it's safe to allow signature overrides
                         for alt_entry in entry.all_alternatives():
-                            if (not alt_entry.cname or
-                                cname == alt_entry.cname):
+                            if not alt_entry.cname or cname == alt_entry.cname:
                                 break # cname not unique!
                         else:
                             can_override = True
@@ -648,8 +631,7 @@ class Scope(object):
         if in_pxd and c_visibility != 'extern':
             entry.defined_in_pxd = 1
         if not defining and not in_pxd and c_visibility != 'extern':
-            error(pos, "Non-extern C function '%s' declared but not defined" %
-                  name)
+            error(pos, "Non-extern C function '%s' declared but not defined" % name)
         if defining:
             entry.is_implemented = True
         if modifiers:
@@ -793,8 +775,7 @@ class BuiltinScope(Scope):
             if self.outer_scope is not None:
                 return self.outer_scope.declare_builtin(name = name, cname = cname, namespace = namespace, c_visibility = c_visibility, visibility = visibility, overridable = overridable, api = api, pos = pos)
             else:
-                error(pos, "undeclared name not builtin: %s" %
-                      name)
+                error(pos, "undeclared name not builtin: %s" % name)
 
     def declare_builtin_cfunction(self, name, cname = None, namespace = None, c_visibility = 'private', visibility = 'public', overridable = 0, api = 0, type = None, python_equiv = None,
                                   utility_code = None):
@@ -820,11 +801,9 @@ class BuiltinScope(Scope):
     def declare_builtin_type(self, name, cname = None, namespace = None, c_visibility = 'private', visibility = 'public', overridable = 0, api = 0, objstruct_cname = None,
                              utility_code = None):
         name = EncodedString(name)
-        type = PyrexTypes.BuiltinObjectType(
-            name, cname, objstruct_cname)
+        type = PyrexTypes.BuiltinObjectType(name, cname, objstruct_cname)
         # WTK: TODO: visibility checking
-        scope = CClassScope(
-            name, outer_scope = None, c_visibility = 'extern')
+        scope = CClassScope(name, outer_scope = None, c_visibility = 'extern')
         scope.directives = {}
         if name == 'bool':
             scope.directives['final'] = True
@@ -833,10 +812,11 @@ class BuiltinScope(Scope):
         entry = self.declare_type(name = name, cname = cname, namespace = namespace, c_visibility = c_visibility, visibility = visibility, overridable = overridable, api = api, type = type)
         entry.utility_code = utility_code
 
-        var_entry = Entry(
-            name = name, cname = "((PyObject*)%s)" % entry.type.typeptr_cname, namespace = namespace, c_visibility = c_visibility, visibility = visibility, overridable = overridable, api = api,
+        var_entry = Entry(name = entry.name,
+            namespace = namespace, c_visibility = c_visibility, visibility = visibility, overridable = overridable, api = api,
             type = self.lookup('type').type, # make sure "type" is the first type declared...
-            pos = entry.pos)
+            pos = entry.pos,
+            cname = "((PyObject*)%s)" % entry.type.typeptr_cname)
         var_entry.is_variable = 1
         var_entry.is_cglobal = 1
         var_entry.is_readonly = 1
@@ -960,8 +940,7 @@ class ModuleScope(Scope):
             elif self.outer_scope is not None:
                 return self.outer_scope.declare_builtin(name = name, cname = cname, namespace = namespace, c_visibility = c_visibility, visibility = visibility, overridable = overridable, api = api, pos = pos)
             else:
-                error(pos, "undeclared name not builtin: %s" %
-                      name)
+                error(pos, "undeclared name not builtin: %s"%name)
         if Options.cache_builtins:
             for entry in self.cached_builtins:
                 if entry.name == name:
@@ -1041,7 +1020,7 @@ class ModuleScope(Scope):
                 # name to appear again, and indeed the generated
                 # code compiles fine.
                 return entry
-                warning(pos, "'%s' redeclared  " % scope.name, 0)
+                warning(pos, "'%s' redeclared  " % as_name, 0)
                 return None
         else:
             entry = self.declare_var(name = as_name, type = py_object_type, pos = pos)
@@ -1129,17 +1108,14 @@ class ModuleScope(Scope):
                 type.module_name = module_name
             else:
                 type.module_name = self.qualified_name
-            type.typeptr_cname = self.mangle(
-                Naming.typeptr_prefix, name)
+            type.typeptr_cname = self.mangle(Naming.typeptr_prefix, name)
             entry = self.declare_type(
                 name = name, cname = cname, namespace = namespace, c_visibility = c_visibility, visibility = visibility, overridable = overridable, api = api, type = type, defining = 0, shadow = shadow, pos = pos)
             entry.is_cclass = True
             if objstruct_cname:
                 type.objstruct_cname = objstruct_cname
             elif c_visibility != 'public':
-                cname = self.mangle(
-                    Naming.objstruct_prefix, name)
-                type.objstruct_cname = cname
+                type.objstruct_cname = self.mangle(Naming.objstruct_prefix, name)
             else:
                 error(entry.pos,
                     "Object name required for 'public' or 'extern' C class")
@@ -1150,9 +1126,7 @@ class ModuleScope(Scope):
         #
         if not type.scope:
             if defining or implementing:
-                scope = CClassScope(
-                    name = name,
-                    outer_scope = self,
+                scope = CClassScope(name = name, outer_scope = self,
                     c_visibility = c_visibility)
                 if base_type and base_type.scope:
                     scope.declare_inherited_c_attributes(base_type.scope)
@@ -1162,11 +1136,9 @@ class ModuleScope(Scope):
                 self.check_for_illegal_incomplete_ctypedef(typedef_flag, pos)
         else:
             if defining and type.scope.defined:
-                error(pos, "C class '%s' already defined" %
-                      name)
+                error(pos, "C class '%s' already defined" % name)
             elif implementing and type.scope.implemented:
-                error(pos, "C class '%s' already implemented" %
-                      name)
+                error(pos, "C class '%s' already implemented" % name)
         #
         #  Fill in options, checking for compatibility with any previous declaration
         #
@@ -1177,8 +1149,7 @@ class ModuleScope(Scope):
         self.check_previous_visibility(
             entry, name = name, cname = cname, namespace = namespace, c_visibility = c_visibility, visibility = visibility, overridable = overridable, api = api, type_name = 'Class', pos = pos)
         if objstruct_cname:
-            if (type.objstruct_cname and
-                type.objstruct_cname != objstruct_cname):
+            if type.objstruct_cname and type.objstruct_cname != objstruct_cname:
                 error(pos, "Object struct name differs from previous declaration")
             type.objstruct_cname = objstruct_cname
         if typeobj_cname:
@@ -1220,10 +1191,8 @@ class ModuleScope(Scope):
             type.vtabslot_cname = Naming.vtabslot_cname
         if type.vtabslot_cname:
             #print "...allocating other vtable related cnames" ###
-            type.vtabstruct_cname = self.mangle(
-                Naming.vtabstruct_prefix, entry.name)
-            type.vtabptr_cname = self.mangle(
-                Naming.vtabptr_prefix, entry.name)
+            type.vtabstruct_cname = self.mangle(Naming.vtabstruct_prefix, entry.name)
+            type.vtabptr_cname = self.mangle(Naming.vtabptr_prefix, entry.name)
 
     def check_c_classes_pxd(self):
         # Performs post-analysis checking and finishing up of extension types
@@ -1239,8 +1208,7 @@ class ModuleScope(Scope):
         for entry in self.c_class_entries:
             # Check defined
             if not entry.type.scope:
-                error(entry.pos, "C class '%s' is declared but not defined"
-                      % entry.name)
+                error(entry.pos, "C class '%s' is declared but not defined" % entry.name)
 
     def check_c_class(self, entry):
         type = entry.type
@@ -1262,8 +1230,7 @@ class ModuleScope(Scope):
         # Allocate vtable name if necessary
         if type.vtabslot_cname:
             #print "ModuleScope.check_c_classes: allocating vtable cname for", self ###
-            type.vtable_cname = self.mangle(
-                Naming.vtable_prefix, entry.name)
+            type.vtable_cname = self.mangle(Naming.vtable_prefix, entry.name)
 
     def check_c_classes(self):
         # Performs post-analysis checking and finishing up of extension types
@@ -1287,8 +1254,7 @@ class ModuleScope(Scope):
                 print("...entry %s %s" % (entry.name, entry))
                 print("......type = ",  entry.type)
                 print("......c_visibility = ", entry.c_visibility)
-                print("......visibility = ",
-                      entry.python.visibility)
+                print("......visibility = ", entry.visibility)
             self.check_c_class(entry)
 
     def check_c_functions(self):
@@ -1311,8 +1277,10 @@ class ModuleScope(Scope):
         # we use a read-only C global variable whose name is an
         # expression that refers to the type object.
         import Builtin
-        var_entry = Entry(
-            name = entry.name, cname = "((PyObject*)%s)" % entry.type.typeptr_cname, type = Builtin.type_type, pos = entry.pos)
+        var_entry = Entry(name = entry.name,
+            type = Builtin.type_type,
+            pos = entry.pos,
+            cname = "((PyObject*)%s)" % entry.type.typeptr_cname)
         var_entry.is_variable = 1
         var_entry.is_cglobal = 1
         var_entry.is_readonly = 1
@@ -1400,12 +1368,10 @@ class LocalScope(Scope):
                 else:
                     if cname.startswith(Naming.cur_scope_cname):
                         cname = cname[len(Naming.cur_scope_cname)+2:]
-                    entry.cname = "%s->%s" % (
-                        outer_scope_cname, cname)
+                    entry.cname = "%s->%s" % (outer_scope_cname, cname)
             elif entry.in_closure:
                 entry.original_cname = entry.cname
-                entry.cname = "%s->%s" % (
-                    Naming.cur_scope_cname, entry.cname)
+                entry.cname = "%s->%s" % (Naming.cur_scope_cname, entry.cname)
 
 class GeneratorExpressionScope(Scope):
     """Scope for generator expressions and comprehensions.  As opposed
@@ -1429,8 +1395,7 @@ class GeneratorExpressionScope(Scope):
                 type = outer_entry.type # may still be 'unspecified_type' !
         # the parent scope needs to generate code for the variable, but
         # this scope must hold its name exclusively
-        cname = '%s%s' % (self.genexp_prefix, self.parent_scope.mangle(
-                Naming.var_prefix, name))
+        cname = '%s%s' % (self.genexp_prefix, self.parent_scope.mangle(Naming.var_prefix, name))
         entry = self.declare(name = name, cname = cname, namespace = namespace, c_visibility = c_visibility, visibility = visibility, overridable = overridable, api = api, type = type, pos = pos)
         entry.is_variable = 1
         self.var_entries.append(entry)
@@ -1599,15 +1564,12 @@ class CClassScope(ClassScope):
                 self.has_pyobject_attrs = 1
             if visibility not in ('private', 'public', 'readonly'):
                 error(pos,
-                      "Attribute of extension type cannot be declared %s" %
-                      visibility)
+                    "Attribute of extension type cannot be declared %s" % visibility)
             if visibility in ('public', 'readonly'):
                 if name == "__weakref__":
                     error(pos, "Special attribute __weakref__ cannot be exposed to Python")
                 if not type.is_pyobject:
-                    #print 'XXX', name, c_visibility == 'extern', c_visibility, visibility, type.create_to_py_utility_code(self), type.__class__  ####### XXXXX BUG! (cimportfrom_T248)
                     if not type.create_to_py_utility_code(self):
-                        #print 'XXX', name, c_visibility == 'extern', c_visibility, visibility  ####### XXXXX BUG! (cimportfrom_T248)
                         error(pos,
                               "C attribute of type '%s' cannot be accessed from Python" % type)
             return entry
@@ -1626,10 +1588,8 @@ class CClassScope(ClassScope):
 
     def declare_pyfunction(self, name, cname = None, namespace = None, c_visibility = 'private', visibility = 'public', overridable = 0, api = 0, allow_redefine = False, pos = None):
         # Add an entry for a method.
-        if name in ('__eq__', '__ne__', '__lt__', '__gt__',
-                                   '__le__', '__ge__'):
-            error(pos, "Special method %s must be implemented via __richcmp__"
-                  % name)
+        if name in ('__eq__', '__ne__', '__lt__', '__gt__', '__le__', '__ge__'):
+            error(pos, "Special method %s must be implemented via __richcmp__" % name)
         if name == "__new__":
             error(pos, "__new__ method of extension type will change semantics "
                 "in a future version of Pyrex and Cython. Use __cinit__ instead.")
@@ -1725,7 +1685,6 @@ class CClassScope(ClassScope):
             entry = self.declare(name = name, cname = cname, namespace = namespace, c_visibility = c_visibility, visibility = visibility, overridable = overridable, api = api, type = py_object_type, pos = pos)
         entry.is_property = 1
         entry.doc = doc
-        # WTK: TODO: adjust PropertyScope attributes
         entry.scope = PropertyScope(name,
             outer_scope = self.global_scope(), parent_scope = self)
         entry.scope.parent_type = self.parent_type