Gentoo Archives: gentoo-portage-dev

From: Brian Dolbec <dolsen@g.o>
To: gentoo-portage-dev@l.g.o
Subject: [gentoo-portage-dev] [PATCH] portage/util.py: Identify the source of a "bad sustitution" error message (bug 542796)
Date: Thu, 23 Apr 2015 16:02:08
Message-Id: 1429804901-13114-1-git-send-email-dolsen@gentoo.org
1 This bug caused great difficulty in determining the cause of the error message.
2 This adds identifying code which states where the error message is coming from.
3 It also adds the actual source which caused the error message in the first place.
4 X-Gentoo-Bug: 542796
5 X-Gentoo-Bug-url: https://bugs.gentoo.org/show_bug.cgi?id=542796
6 X-Gentoo-forum-thread: https://forums.gentoo.org/viewtopic-t-1014842.html
7 ---
8 pym/portage/util/__init__.py | 15 +++++++++------
9 1 file changed, 9 insertions(+), 6 deletions(-)
10
11 diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py
12 index 48cd1b7..2ab38f3 100644
13 --- a/pym/portage/util/__init__.py
14 +++ b/pym/portage/util/__init__.py
15 @@ -777,6 +777,7 @@ def getconfig(mycfg, tolerant=False, allow_sourcing=False, expand=True,
16
17 _varexpand_word_chars = frozenset(string.ascii_letters + string.digits + "_")
18 _varexpand_unexpected_eof_msg = "unexpected EOF while looking for matching `}'"
19 +_varexpand_msgid = "portage.util varexpand(); "
20
21 def varexpand(mystring, mydict=None, error_leader=None):
22 if mydict is None:
23 @@ -859,10 +860,11 @@ def varexpand(mystring, mydict=None, error_leader=None):
24 while mystring[pos] in _varexpand_word_chars:
25 if pos + 1 >= len(mystring):
26 if braced:
27 - msg = _varexpand_unexpected_eof_msg
28 + msg = '%s\n %s' %(_varexpand_unexpected_eof_msg,
29 + mystring)
30 if error_leader is not None:
31 msg = error_leader() + msg
32 - writemsg(msg + "\n", noiselevel=-1)
33 + writemsg(_varexpand_msgid + msg + "\n", noiselevel=-1)
34 return ""
35 else:
36 pos += 1
37 @@ -871,10 +873,11 @@ def varexpand(mystring, mydict=None, error_leader=None):
38 myvarname = mystring[myvstart:pos]
39 if braced:
40 if mystring[pos] != "}":
41 - msg = _varexpand_unexpected_eof_msg
42 + msg = '%s\n %s' %(_varexpand_unexpected_eof_msg,
43 + mystring)
44 if error_leader is not None:
45 msg = error_leader() + msg
46 - writemsg(msg + "\n", noiselevel=-1)
47 + writemsg(_varexpand_msgid + msg + "\n", noiselevel=-1)
48 return ""
49 else:
50 pos += 1
51 @@ -882,10 +885,10 @@ def varexpand(mystring, mydict=None, error_leader=None):
52 msg = "$"
53 if braced:
54 msg += "{}"
55 - msg += ": bad substitution"
56 + msg += ": bad substitution for:\n %s" % mystring
57 if error_leader is not None:
58 msg = error_leader() + msg
59 - writemsg(msg + "\n", noiselevel=-1)
60 + writemsg(_varexpand_msgid + msg + "\n", noiselevel=-1)
61 return ""
62 numvars += 1
63 if myvarname in mydict:
64 --
65 2.3.4

Replies