public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-portage-dev] [PATCH] portage/util.py: Identify the source of a "bad sustitution" error message (bug 542796)
@ 2015-04-23 16:01 Brian Dolbec
  2015-04-23 17:38 ` Zac Medico
  0 siblings, 1 reply; 5+ messages in thread
From: Brian Dolbec @ 2015-04-23 16:01 UTC (permalink / raw
  To: gentoo-portage-dev

This bug caused great difficulty in determining the cause of the error message.
This adds identifying code which states where the error message is coming from.
It also adds the actual source which caused the error message in the first place.
X-Gentoo-Bug: 542796
X-Gentoo-Bug-url: https://bugs.gentoo.org/show_bug.cgi?id=542796
X-Gentoo-forum-thread: https://forums.gentoo.org/viewtopic-t-1014842.html
---
 pym/portage/util/__init__.py | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py
index 48cd1b7..2ab38f3 100644
--- a/pym/portage/util/__init__.py
+++ b/pym/portage/util/__init__.py
@@ -777,6 +777,7 @@ def getconfig(mycfg, tolerant=False, allow_sourcing=False, expand=True,
 
 _varexpand_word_chars = frozenset(string.ascii_letters + string.digits + "_")
 _varexpand_unexpected_eof_msg = "unexpected EOF while looking for matching `}'"
+_varexpand_msgid = "portage.util varexpand(); "
 
 def varexpand(mystring, mydict=None, error_leader=None):
 	if mydict is None:
@@ -859,10 +860,11 @@ def varexpand(mystring, mydict=None, error_leader=None):
 				while mystring[pos] in _varexpand_word_chars:
 					if pos + 1 >= len(mystring):
 						if braced:
-							msg = _varexpand_unexpected_eof_msg
+							msg = '%s\n    %s' %(_varexpand_unexpected_eof_msg,
+								mystring)
 							if error_leader is not None:
 								msg = error_leader() + msg
-							writemsg(msg + "\n", noiselevel=-1)
+							writemsg(_varexpand_msgid + msg + "\n", noiselevel=-1)
 							return ""
 						else:
 							pos += 1
@@ -871,10 +873,11 @@ def varexpand(mystring, mydict=None, error_leader=None):
 				myvarname = mystring[myvstart:pos]
 				if braced:
 					if mystring[pos] != "}":
-						msg = _varexpand_unexpected_eof_msg
+						msg = '%s\n    %s' %(_varexpand_unexpected_eof_msg,
+							mystring)
 						if error_leader is not None:
 							msg = error_leader() + msg
-						writemsg(msg + "\n", noiselevel=-1)
+						writemsg(_varexpand_msgid + msg + "\n", noiselevel=-1)
 						return ""
 					else:
 						pos += 1
@@ -882,10 +885,10 @@ def varexpand(mystring, mydict=None, error_leader=None):
 					msg = "$"
 					if braced:
 						msg += "{}"
-					msg += ": bad substitution"
+					msg += ": bad substitution for:\n    %s" % mystring
 					if error_leader is not None:
 						msg = error_leader() + msg
-					writemsg(msg + "\n", noiselevel=-1)
+					writemsg(_varexpand_msgid + msg + "\n", noiselevel=-1)
 					return ""
 				numvars += 1
 				if myvarname in mydict:
-- 
2.3.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-04-23 18:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-23 16:01 [gentoo-portage-dev] [PATCH] portage/util.py: Identify the source of a "bad sustitution" error message (bug 542796) Brian Dolbec
2015-04-23 17:38 ` Zac Medico
2015-04-23 17:51   ` [gentoo-portage-dev] [PATCH] LinkageMapElf.rebuild: pass error_leader to varexpand " Zac Medico
2015-04-23 18:08   ` [gentoo-portage-dev] [PATCH] portage/util.py: Identify the source of a "bad sustitution" error message " Brian Dolbec
2015-04-23 18:21     ` Zac Medico

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox