* Raise PermissionDenied from getconfig() when appropriate.
authorZac Medico <zmedico@gentoo.org>
Tue, 11 Dec 2007 23:44:59 +0000 (23:44 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 11 Dec 2007 23:44:59 +0000 (23:44 -0000)
* When available, make getconfig() include an invalid token
  in a ParseError message.
(trunk r8883)

svn path=/main/branches/2.1.2/; revision=8885

pym/portage_util.py

index 8e4a8cb44df72bca8a64e5e2a17bbad60cd6c88c..b615108c3983f29289ba807cbab0581f97386727 100644 (file)
@@ -294,6 +294,8 @@ def getconfig(mycfg, tolerant=0, allow_sourcing=False, expand=True):
        try:
                f=open(mycfg,'r')
        except IOError, e:
+               if e.errno == PermissionDenied.errno:
+                       raise PermissionDenied(mycfg)
                if e.errno != errno.ENOENT:
                        raise
                return None
@@ -324,9 +326,9 @@ def getconfig(mycfg, tolerant=0, allow_sourcing=False, expand=True):
                                #invalid token
                                #lex.error_leader(self.filename,lex.lineno)
                                if not tolerant:
-                                       writemsg("!!! Invalid token (not \"=\") "+str(equ)+"\n",
-                                               noiselevel=-1)
-                                       raise Exception("ParseError: Invalid token (not '='): "+str(mycfg)+": line "+str(lex.lineno))
+                                       raise Exception("ParseError: Invalid token " + \
+                                               "'%s' (not '='): %s: line %s" % \
+                                               (equ, mycfg, lex.lineno))
                                else:
                                        return mykeys
                        val=lex.get_token()