public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Brian Dolbec <dolsen@gentoo.org>
To: gentoo-portage-dev@lists.gentoo.org
Subject: [gentoo-portage-dev] [PATCH] portage/util.py: Identify the source of a "bad sustitution" error message (bug 542796)
Date: Thu, 23 Apr 2015 09:01:41 -0700	[thread overview]
Message-ID: <1429804901-13114-1-git-send-email-dolsen@gentoo.org> (raw)

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



             reply	other threads:[~2015-04-23 16:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-23 16:01 Brian Dolbec [this message]
2015-04-23 17:38 ` [gentoo-portage-dev] [PATCH] portage/util.py: Identify the source of a "bad sustitution" error message (bug 542796) 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1429804901-13114-1-git-send-email-dolsen@gentoo.org \
    --to=dolsen@gentoo.org \
    --cc=gentoo-portage-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox