bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* [PATCH] gnulib-tool.py: Comment out undefined variable.
@ 2024-02-21 11:36 Collin Funk
  2024-02-21 16:08 ` Bruno Haible
  0 siblings, 1 reply; 4+ messages in thread
From: Collin Funk @ 2024-02-21 11:36 UTC (permalink / raw)
  To: bug-gnulib

[-- Attachment #1: Type: text/plain, Size: 946 bytes --]

I started to look at the Python gnulib-tool and ran into this error that
should be easily reproducible:

[collin@debian src]$ gnulib-tool.py --create-testdir --dir test dummy
Module list with included dependencies (indented):
  dummy
File list:
  lib/dummy.c
  m4/00gnulib.m4
  m4/gnulib-common.m4
  m4/zzgnulib.m4
Traceback (most recent call last):
  File "/home/collin/.local/bin/gnulib-tool.py", line 1171, in <module>
    main()
  File "/home/collin/.local/bin/gnulib-tool.py", line 908, in main
    testdir.execute()
  File "/home/collin/.local/src/gnulib/pygnulib/GLTestDir.py", line 503,
in execute
    self.config.setAuxDir(saved_auxdir)
                          ^^^^^^^^^^^^
NameError: name 'saved_auxdir' is not defined

I commented out the offending line instead of removing it just in case
it is useful in the future. The previous command should work with the
dummy module so I can start comparing the output while learning the code.

[-- Attachment #2: 0001-gnulib-tool.py-Comment-out-undefined-variable.patch --]
[-- Type: text/x-patch, Size: 1417 bytes --]

From 6d94d65bfb0afc77c28b9c3a4633d156eb94906a Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.funk1@gmail.com>
Date: Wed, 21 Feb 2024 03:25:37 -0800
Subject: [PATCH] gnulib-tool.py: Comment out undefined variable.

* pygnulib/GLTestDir.py (GLTestDir.execute): Comment out line
that causes a NameError exception when executed.
---
 ChangeLog             | 6 ++++++
 pygnulib/GLTestDir.py | 3 ++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index dfc1641e74..60c3dd4e8c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-02-21  Collin Funk  <collin.funk1@gmail.com>
+
+	gnulib-tool.py: Comment out undefined variable.
+	* pygnulib/GLTestDir.py (GLTestDir.execute): Comment out line
+	that causes a NameError exception when executed.
+
 2024-02-20  Bruno Haible  <bruno@clisp.org>
 
 	unimetadata/u-version: Add tests.
diff --git a/pygnulib/GLTestDir.py b/pygnulib/GLTestDir.py
index ae8537cff4..52171fdd9e 100644
--- a/pygnulib/GLTestDir.py
+++ b/pygnulib/GLTestDir.py
@@ -500,7 +500,8 @@ class GLTestDir(object):
                     file.write(emit)
 
                 # Restore changed variables.
-                self.config.setAuxDir(saved_auxdir)
+                # FIXME: Undefined?
+                # self.config.setAuxDir(saved_auxdir)
                 auxdir = self.config['auxdir']
                 subdirs_with_configure_ac += [testsbase]
 
-- 
2.39.2


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

* Re: [PATCH] gnulib-tool.py: Comment out undefined variable.
  2024-02-21 11:36 [PATCH] gnulib-tool.py: Comment out undefined variable Collin Funk
@ 2024-02-21 16:08 ` Bruno Haible
  2024-02-21 17:17   ` Collin Funk
  0 siblings, 1 reply; 4+ messages in thread
From: Bruno Haible @ 2024-02-21 16:08 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Collin Funk

Collin Funk wrote:
>     self.config.setAuxDir(saved_auxdir)
>                           ^^^^^^^^^^^^
> NameError: name 'saved_auxdir' is not defined
> 
> I commented out the offending line instead of removing it just in case
> it is useful in the future.

I suppose it is not much more work to fix this line for real?
Hints:
  - If there is no variable 'saved_auxdir' in this function, maybe there
    is a variable 'auxdir'?
  - What do the comments hint at?
  - What does the history of the file ('gitk pygnulib/GLTestDir.py',
    'git annotate pygnulib/GLTestDir.py') tell you?

Bruno





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

* Re: [PATCH] gnulib-tool.py: Comment out undefined variable.
  2024-02-21 16:08 ` Bruno Haible
@ 2024-02-21 17:17   ` Collin Funk
  2024-02-21 17:29     ` Bruno Haible
  0 siblings, 1 reply; 4+ messages in thread
From: Collin Funk @ 2024-02-21 17:17 UTC (permalink / raw)
  To: Bruno Haible, bug-gnulib

[-- Attachment #1: Type: text/plain, Size: 1118 bytes --]

On 2/21/24 8:08 AM, Bruno Haible wrote:
> I suppose it is not much more work to fix this line for real?
> Hints:
>   - If there is no variable 'saved_auxdir' in this function, maybe there
>     is a variable 'auxdir'?
>   - What do the comments hint at?
>   - What does the history of the file ('gitk pygnulib/GLTestDir.py',
>     'git annotate pygnulib/GLTestDir.py') tell you?

Thanks for the tips. I should have done that in the first place...
I think that this patch would be the correct way to fix the issue.

It seems that your commit 01cd78f9d682ff75cc5ab1c2d21b911bdd9215b8
accidentally caused this. While cleaning up the handling of paths, I
think you accidentally removed this variable. This patch seems to
restore the behavior of the previous commits.

Then:
	gnulib-tool --create-testdir --dir t1 dummy
	gnulib-tool.py --create-testdir --dir t2 dummy

Both t1/gltests/configure.ac and t2/gltests/configure.ac start with:

# Process this file with autoconf to produce a configure script.
AC_INIT([dummy], [0])
AC_CONFIG_AUX_DIR([../build-aux])
AM_INIT_AUTOMAKE

Not a complete test but better than before :)

[-- Attachment #2: 0001-gnulib-tool.py-Fix-undefined-variable-while-emitting.patch --]
[-- Type: text/x-patch, Size: 1742 bytes --]

From b2ee9537298dd76d683ec9c4298f22c53f45f6f5 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.funk1@gmail.com>
Date: Wed, 21 Feb 2024 08:54:51 -0800
Subject: [PATCH] gnulib-tool.py: Fix undefined variable while emitting
 testdir.

* pygnulib/GLTestDir.py (GLTestDir.execute): Fix undefined
variable refrence caused by commit
01cd78f9d682ff75cc5ab1c2d21b911bdd9215b8.
Restore the previous auxdir when finished writing the
configure.ac file in the test directory.
---
 ChangeLog             | 9 +++++++++
 pygnulib/GLTestDir.py | 1 +
 2 files changed, 10 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 9779a09ac6..e313032178 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-02-21  Collin Funk  <collin.funk1@gmail.com>
+
+	gnulib-tool.py: Fix undefined variable while emitting testdir.
+	* pygnulib/GLTestDir.py (GLTestDir.execute): Fix undefined
+	variable refrence caused by commit
+	01cd78f9d682ff75cc5ab1c2d21b911bdd9215b8.
+	Restore the previous auxdir when finished writing the
+	configure.ac file in the test directory.
+
 2024-02-21  Bruno Haible  <bruno@clisp.org>
 
 	*printf-posix: Disable support for the 'n' directive by default.
diff --git a/pygnulib/GLTestDir.py b/pygnulib/GLTestDir.py
index ae8537cff4..144798bd01 100644
--- a/pygnulib/GLTestDir.py
+++ b/pygnulib/GLTestDir.py
@@ -406,6 +406,7 @@ class GLTestDir(object):
                     file.write(emit)
                 # Viewed from the $testsbase subdirectory, $auxdir is different.
                 emit = ''
+                saved_auxdir = auxdir
                 auxdir = os.path.normpath(joinpath(relinverse(testsbase), auxdir))
                 self.config.setAuxDir(auxdir)
                 # Create $testsbase/configure.ac.
-- 
2.39.2


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

* Re: [PATCH] gnulib-tool.py: Comment out undefined variable.
  2024-02-21 17:17   ` Collin Funk
@ 2024-02-21 17:29     ` Bruno Haible
  0 siblings, 0 replies; 4+ messages in thread
From: Bruno Haible @ 2024-02-21 17:29 UTC (permalink / raw)
  To: bug-gnulib, Collin Funk

Collin Funk wrote:
> It seems that your commit 01cd78f9d682ff75cc5ab1c2d21b911bdd9215b8
> accidentally caused this. While cleaning up the handling of paths, I
> think you accidentally removed this variable.

Yep. Thanks for the fix! Applied.

Bruno





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

end of thread, other threads:[~2024-02-21 17:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-21 11:36 [PATCH] gnulib-tool.py: Comment out undefined variable Collin Funk
2024-02-21 16:08 ` Bruno Haible
2024-02-21 17:17   ` Collin Funk
2024-02-21 17:29     ` Bruno Haible

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).