1.1 --- a/micropython/__init__.py Fri May 18 01:21:20 2012 +0200
1.2 +++ b/micropython/__init__.py Sat May 19 01:33:10 2012 +0200
1.3 @@ -46,6 +46,7 @@
1.4 import micropython.table
1.5 import bisect
1.6 import os
1.7 +#import sys
1.8
1.9 try:
1.10 set
1.11 @@ -720,7 +721,7 @@
1.12 try:
1.13 attr = objtable.access(objname, attrname)
1.14 except TableError:
1.15 - #print "Warning: object type %r does not support attribute %r" % (objname, attrname)
1.16 + #print >>sys.stderr, "Warning: object type %r does not support attribute %r" % (objname, attrname)
1.17 continue
1.18
1.19 # Get the real identity of the attribute in order to
2.1 --- a/micropython/common.py Fri May 18 01:21:20 2012 +0200
2.2 +++ b/micropython/common.py Sat May 19 01:33:10 2012 +0200
2.3 @@ -20,6 +20,7 @@
2.4 """
2.5
2.6 import operator
2.7 +import sys
2.8
2.9 try:
2.10 set
2.11 @@ -358,11 +359,11 @@
2.12 attrnames = attrnames or ()
2.13 objtypes = objtable.all_possible_objects_plus_status(attrnames)
2.14 if not objtypes:
2.15 - print "Warning: usage in %r for %r finds no object supporting all attributes %r" % (
2.16 + print >>sys.stderr, "Warning: usage in %r for %r finds no object supporting all attributes %r" % (
2.17 unit_name, name, attrnames)
2.18 objtypes = objtable.any_possible_objects_plus_status(attrnames)
2.19 if not objtypes:
2.20 - print "Warning: usage in %r for %r finds no object supporting any attributes %r" % (
2.21 + print >>sys.stderr, "Warning: usage in %r for %r finds no object supporting any attributes %r" % (
2.22 unit_name, name, attrnames)
2.23
2.24 all_objtypes.update(objtypes)
3.1 --- a/micropython/data.py Fri May 18 01:21:20 2012 +0200
3.2 +++ b/micropython/data.py Sat May 19 01:33:10 2012 +0200
3.3 @@ -54,6 +54,7 @@
3.4
3.5 from micropython.program import ReplaceableContext, PlaceholderContext
3.6 from micropython.common import *
3.7 +import sys
3.8
3.9 def shortrepr(obj):
3.10 if obj is None:
3.11 @@ -238,7 +239,7 @@
3.12 """
3.13
3.14 if value is None:
3.15 - print "Warning: name %r in namespace %r has an unknown value (evaluated to None)." % (name, self.full_name())
3.16 + print >>sys.stderr, "Warning: name %r in namespace %r has an unknown value (evaluated to None)." % (name, self.full_name())
3.17 value = make_instance()
3.18
3.19 if name in self.globals:
3.20 @@ -1622,7 +1623,7 @@
3.21 self.allattr.update(self.all_class_attributes())
3.22 for name, attr in self.instance_attributes().items():
3.23 if self.allattr.has_key(name) and name != "__class__":
3.24 - print "Warning: instance attribute %r in %r overrides class attribute." % (name, self)
3.25 + print >>sys.stderr, "Warning: instance attribute %r in %r overrides class attribute." % (name, self)
3.26 self.allattr[name] = attr
3.27 return self.allattr
3.28
4.1 --- a/micropython/inspect.py Fri May 18 01:21:20 2012 +0200
4.2 +++ b/micropython/inspect.py Sat May 19 01:33:10 2012 +0200
4.3 @@ -75,6 +75,7 @@
4.4 from micropython.common import *
4.5 from micropython.data import *
4.6 import compiler.ast
4.7 +import sys
4.8
4.9 # Program visitors.
4.10
4.11 @@ -672,7 +673,7 @@
4.12
4.13 elif isinstance(value, Module):
4.14 self.store_module_attr(attrname, value)
4.15 - print "Warning: attribute %r of module %r set outside the module." % (node.attrname, expr.get_value().name)
4.16 + print >>sys.stderr, "Warning: attribute %r of module %r set outside the module." % (node.attrname, expr.get_value().name)
4.17
4.18 elif isinstance(value, Class):
4.19 self.store_class_attr(attrname, value)
4.20 @@ -699,7 +700,7 @@
4.21
4.22 def visitAssName(self, node):
4.23 if hasattr(node, "flags") and node.flags == "OP_DELETE":
4.24 - print "Warning: deletion of attribute %r in %r is not supported." % (node.name, self.full_name())
4.25 + print >>sys.stderr, "Warning: deletion of attribute %r in %r is not supported." % (node.name, self.full_name())
4.26 #raise InspectError("Deletion of attribute %r is not supported." % node.name)
4.27
4.28 self.store(node.name, self.expr)
4.29 @@ -765,11 +766,11 @@
4.30 """
4.31
4.32 if self.namespaces:
4.33 - print "Warning: class %r in %r is not global: ignored." % (node.name, self.namespaces[-1].full_name())
4.34 + print >>sys.stderr, "Warning: class %r in %r is not global: ignored." % (node.name, self.namespaces[-1].full_name())
4.35 return
4.36 else:
4.37 if self.in_loop:
4.38 - print "Warning: class %r in %r defined in a loop." % (node.name, self.full_name())
4.39 + print >>sys.stderr, "Warning: class %r in %r defined in a loop." % (node.name, self.full_name())
4.40
4.41 cls = get_class(node.name, self.get_namespace(), self, node)
4.42
4.43 @@ -933,7 +934,7 @@
4.44 module = self.importer.load(node.modname, 1)
4.45
4.46 #if module is None:
4.47 - # print "Warning:", node.modname, "not imported."
4.48 + # print >>sys.stderr, "Warning:", node.modname, "not imported."
4.49
4.50 for name, alias in node.names:
4.51 if name != "*":
5.1 --- a/micropython/report.py Fri May 18 01:21:20 2012 +0200
5.2 +++ b/micropython/report.py Sat May 19 01:33:10 2012 +0200
5.3 @@ -565,7 +565,7 @@
5.4 bases = cls.bases
5.5 self.stream.write("<div class='class nowrap' id='%s'>\n" % cls.full_name())
5.6 else:
5.7 - print "Warning: class %s not recognised!" % node.name
5.8 + print >>sys.stderr, "Warning: class %s not recognised!" % node.name
5.9 return
5.10
5.11 # Write the declaration line.
5.12 @@ -667,7 +667,7 @@
5.13 fn = node.unit
5.14 self.stream.write("<div class='function nowrap' id='%s'>\n" % fn.full_name())
5.15 else:
5.16 - print "Warning: function %s not recognised!" % node.name
5.17 + print >>sys.stderr, "Warning: function %s not recognised!" % node.name
5.18 return
5.19
5.20 # Write the declaration line.
5.21 @@ -1070,7 +1070,7 @@
5.22 if hasattr(node, "unit"):
5.23 fn = node.unit
5.24 else:
5.25 - print "Warning: function %s not recognised!" % node.name
5.26 + print >>sys.stderr, "Warning: function %s not recognised!" % node.name
5.27 return
5.28
5.29 self._span_start("lambda")
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/tests/for_if_usage.py Sat May 19 01:33:10 2012 +0200
6.3 @@ -0,0 +1,18 @@
6.4 +#!/usr/bin/env python
6.5 +
6.6 +class C:
6.7 + p = 1
6.8 + q = 2
6.9 +
6.10 +c = C()
6.11 +a = 1
6.12 +
6.13 +for x in 0, 1, 2:
6.14 + if a:
6.15 + b = c.p
6.16 + else:
6.17 + b = c.q
6.18 +
6.19 +result_1 = b
6.20 +
6.21 +# vim: tabstop=4 expandtab shiftwidth=4