# HG changeset patch # User Paul Boddie # Date 1232240981 -3600 # Node ID ac2d54b745165a3e84fae07784e0145472b399f3 # Parent 9abe641af4e62799415a7828bb544e4e5e1c83c0 Moved InspectError usage into the inspect module. diff -r 9abe641af4e6 -r ac2d54b74516 micropython/data.py --- a/micropython/data.py Sat Jan 17 23:25:17 2009 +0100 +++ b/micropython/data.py Sun Jan 18 02:09:41 2009 +0100 @@ -3,7 +3,7 @@ """ Data classes. -Copyright (C) 2007, 2008 Paul Boddie +Copyright (C) 2007, 2008, 2009 Paul Boddie This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -152,8 +152,9 @@ def make_global(self, name): if not self.namespace.has_key(name): self.globals.add(name) + return 1 else: - raise InspectError(self.full_name(), self.astnode, "Name %r is both global and local in %r" % (name, self.full_name())) + return 0 def get_assignments(self, name): if self.assignments.has_key(name): @@ -788,8 +789,9 @@ def make_global(self, name): if name not in self.argnames and not self.has_key(name): self.globals.add(name) + return 1 else: - raise InspectError(self.full_name(), self.astnode, "Name %r is global and local in %r" % (name, self.full_name())) + return 0 def parameters(self): diff -r 9abe641af4e6 -r ac2d54b74516 micropython/inspect.py --- a/micropython/inspect.py Sat Jan 17 23:25:17 2009 +0100 +++ b/micropython/inspect.py Sun Jan 18 02:09:41 2009 +0100 @@ -3,7 +3,7 @@ """ Inspect source files, obtaining details of classes and attributes. -Copyright (C) 2007, 2008 Paul Boddie +Copyright (C) 2007, 2008, 2009 Paul Boddie This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -630,7 +630,9 @@ def visitGlobal(self, node): if self.namespaces: for name in node.names: - self.namespaces[-1].make_global(name) + ns = self.namespaces[-1] + if not ns.make_global(name): + raise InspectError(ns.full_name(), node, "Name %r is global and local in %r" % (name, ns.full_name())) # Record a global entry for the name in the module.