Use writemsg for unicode safety in set messages.
authorZac Medico <zmedico@gentoo.org>
Wed, 13 Mar 2013 15:19:06 +0000 (08:19 -0700)
committerZac Medico <zmedico@gentoo.org>
Wed, 13 Mar 2013 15:19:06 +0000 (08:19 -0700)
pym/_emerge/actions.py
pym/_emerge/depgraph.py

index 008a5d57986de8999ba0ea559cecd864fc549552..2c5a1b383bbad9b7ef849498e21243b30220b879 100644 (file)
@@ -3429,15 +3429,18 @@ def expand_set_arguments(myfiles, myaction, root_config):
                                        return (None, 1)
                                if myaction in unmerge_actions and \
                                                not sets[s].supportsOperation("unmerge"):
-                                       sys.stderr.write("emerge: the given set '%s' does " % s + \
-                                               "not support unmerge operations\n")
+                                       writemsg_level("emerge: the given set '%s' does " % s + \
+                                               "not support unmerge operations\n",
+                                               level=logging.ERROR, noiselevel=-1)
                                        retval = 1
                                elif not set_atoms:
-                                       print("emerge: '%s' is an empty set" % s)
+                                       writemsg_level("emerge: '%s' is an empty set\n" % s,
+                                               level=logging.INFO, noiselevel=-1)
                                else:
                                        newargs.extend(set_atoms)
-                               for e in sets[s].errors:
-                                       print(e)
+                               for error_msg in sets[s].errors:
+                                       writemsg_level("%s\n" % (error_msg,),
+                                               level=logging.ERROR, noiselevel=-1)
                else:
                        newargs.append(a)
        return (newargs, retval)
index dfef6a76cd7b52c8e317c4d1e62307567f5c820e..326dd68ddb750ccc7c9a4449b2d099bc77badaea 100644 (file)
@@ -2742,7 +2742,8 @@ class depgraph(object):
                                                        noiselevel=-1)
                                                for pset in list(depgraph_sets.sets.values()) + [sets[s]]:
                                                        for error_msg in pset.errors:
-                                                               sys.stderr.write("%s\n" % (error_msg,))
+                                                               writemsg_level("%s\n" % (error_msg,),
+                                                                       level=logging.ERROR, noiselevel=-1)
 
                                                writemsg_level(("emerge: the given set '%s' "
                                                        "contains a non-existent set named '%s'.\n") % \
@@ -7076,8 +7077,9 @@ class depgraph(object):
 
                for depgraph_sets in self._dynamic_config.sets.values():
                        for pset in depgraph_sets.sets.values():
-                               for e in pset.errors:
-                                       sys.stderr.write("%s\n" % (e,))
+                               for error_msg in pset.errors:
+                                       writemsg_level("%s\n" % (error_msg,),
+                                               level=logging.ERROR, noiselevel=-1)
 
                # TODO: Add generic support for "set problem" handlers so that
                # the below warnings aren't special cases for world only.