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

svn path=/main/trunk/; revision=8883

pym/portage/util.py

index 1e3b9cc306ebc694e72287c6ab5865449a0ce36e..fa816d728ea1707402b3ddb59b9e7747fc8336e0 100644 (file)
@@ -308,6 +308,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
@@ -338,9 +340,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()