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

* Re: [gentoo-portage-dev] [PATCH] portage/util.py: Identify the source of a "bad sustitution" error message (bug 542796)
  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
  0 siblings, 2 replies; 5+ messages in thread
From: Zac Medico @ 2015-04-23 17:38 UTC (permalink / raw
  To: gentoo-portage-dev

On 04/23/2015 09:01 AM, Brian Dolbec wrote:
> 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

Since varexpand already has an error_leader argument, we could use that
to report the source. The relevant varexpand calls are in
pym/portage/util/_dyn_libs/LinkageMapELF.py, added in commit
f1c1b8a77eebf7713b32e5f9945690f60f4f46de.
-- 
Thanks,
Zac


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

* [gentoo-portage-dev] [PATCH] LinkageMapElf.rebuild: pass error_leader to varexpand (bug 542796)
  2015-04-23 17:38 ` Zac Medico
@ 2015-04-23 17:51   ` 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
  1 sibling, 0 replies; 5+ messages in thread
From: Zac Medico @ 2015-04-23 17:51 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: Zac Medico

Since commit f1c1b8a77eebf7713b32e5f9945690f60f4f46de,
LinkageMapElf.rebuild could produce mysterious "bad substitution"
messages.

Fixes: f1c1b8a77eeb ("Generate soname dependency metadata (bug 282639)")
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/_dyn_libs/LinkageMapELF.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/pym/portage/util/_dyn_libs/LinkageMapELF.py b/pym/portage/util/_dyn_libs/LinkageMapELF.py
index c44666a..f4d8b5d 100644
--- a/pym/portage/util/_dyn_libs/LinkageMapELF.py
+++ b/pym/portage/util/_dyn_libs/LinkageMapELF.py
@@ -339,7 +339,8 @@ class LinkageMapELF(object):
 			obj = entry.filename
 			soname = entry.soname
 			expand = {"ORIGIN": os.path.dirname(entry.filename)}
-			path = frozenset(normalize_path(varexpand(x, expand))
+			path = frozenset(normalize_path(
+				varexpand(x, expand, error_leader=lambda: "%s: " % location))
 				for x in entry.runpaths)
 			path = frozensets.setdefault(path, path)
 			needed = frozenset(entry.needed)
-- 
2.3.1



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

* Re: [gentoo-portage-dev] [PATCH] portage/util.py: Identify the source of a "bad sustitution" error message (bug 542796)
  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   ` Brian Dolbec
  2015-04-23 18:21     ` Zac Medico
  1 sibling, 1 reply; 5+ messages in thread
From: Brian Dolbec @ 2015-04-23 18:08 UTC (permalink / raw
  To: gentoo-portage-dev

On Thu, 23 Apr 2015 10:38:24 -0700
Zac Medico <zmedico@gentoo.org> wrote:

> On 04/23/2015 09:01 AM, Brian Dolbec wrote:
> > 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
> 
> Since varexpand already has an error_leader argument, we could use
> that to report the source. The relevant varexpand calls are in
> pym/portage/util/_dyn_libs/LinkageMapELF.py, added in commit
> f1c1b8a77eebf7713b32e5f9945690f60f4f46de.


Yes, that is a good idea.  Should we do similar for all varexpand calls?

Also, That is in addition to identifying that the message is being
generated in portage.util varexpand()?  So we don't keep looking for
the problem/source in the wrong place like we just did?
-- 
Brian Dolbec <dolsen>



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

* Re: [gentoo-portage-dev] [PATCH] portage/util.py: Identify the source of a "bad sustitution" error message (bug 542796)
  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
  0 siblings, 0 replies; 5+ messages in thread
From: Zac Medico @ 2015-04-23 18:21 UTC (permalink / raw
  To: gentoo-portage-dev

On 04/23/2015 11:08 AM, Brian Dolbec wrote:
> On Thu, 23 Apr 2015 10:38:24 -0700
> Zac Medico <zmedico@gentoo.org> wrote:
> 
>> On 04/23/2015 09:01 AM, Brian Dolbec wrote:
>>> 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
>>
>> Since varexpand already has an error_leader argument, we could use
>> that to report the source. The relevant varexpand calls are in
>> pym/portage/util/_dyn_libs/LinkageMapELF.py, added in commit
>> f1c1b8a77eebf7713b32e5f9945690f60f4f46de.
> 
> 
> Yes, that is a good idea.  Should we do similar for all varexpand calls?

Sure. Most varexpand calls are via portage.util.getconfig, which already
passes in the error_leader parameter. There are a small number of
varexpand calls elsewhere which aren't using the error_leader parameter yet.

> Also, That is in addition to identifying that the message is being
> generated in portage.util varexpand()?  So we don't keep looking for
> the problem/source in the wrong place like we just did?

I think it's enough to use the error_leader parameter, since generally
that should give enough information to isolate the source of the problem.
-- 
Thanks,
Zac


^ permalink raw reply	[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