mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Julian Braha <julianbraha@gmail.com>
To: pavee.zheng@gmail.com, Nathan Chancellor <nathan@kernel.org>,
	Nicolas Schier <nsc@kernel.org>
Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] kconfig: tests: avoid mutating extra_env dicts in Conf
Date: Fri, 4 Dec 2026 14:16:46 +0000	[thread overview]
Message-ID: <22852354-3a65-427a-a438-477a1b34d217@gmail.com> (raw)
In-Reply-To: <20261204-patch-kconfig-tests-extra-env-v2-1-fe3787d1b040@gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 1681 bytes --]

On 12/4/26 10:26, Pavee Zheng via B4 Relay wrote:
> From: Pavee Zheng <pavee.zheng@gmail.com>
> 
> Ruff's B006 (mutable-argument-default) lint flags using mutable data
> structures such as {} as default argument values because Python
> evaluates default arguments once at function definition time and shares
> the same object across all calls, so in-place mutations persist across
> subsequent calls.
> 
> Conf._run_conf() and Conf._allconfig() both declare extra_env={} and
> mutate extra_env in place:
> 
> - Conf._allconfig() assigns extra_env['KCONFIG_ALLCONFIG'] when
>   all_config is set. No existing test currently passes a non-None
>   all_config to allyesconfig(), allmodconfig(), allnoconfig(), or
>   alldefconfig(), so this does not trigger a failure today, but a
>   future caller doing so would leave a stale KCONFIG_ALLCONFIG entry
>   in the shared default dictionary for subsequent calls in the same
>   pytest session.
> - Conf._run_conf() assigns extra_env['srctree'], mutating both its
>   default dictionary and caller-owned dictionaries passed via
>   extra_env (such as warn_changed_input in
>   scripts/kconfig/tests/warn_changed_input/__init__.py).
> 
> As a defensive cleanup and readability improvement, default extra_env
> to None in both methods. In _run_conf(), merge extra_env into the local
> env dictionary and set env['srctree'] there instead of mutating
> extra_env. In _allconfig(), build a fresh local dictionary copy before
> inserting KCONFIG_ALLCONFIG.
> 
> Signed-off-by: Pavee Zheng <pavee.zheng@gmail.com>
Tested-by: Julian Braha <julianbraha@gmail.com>
Reviewed-by: Julian Braha <julianbraha@gmail.com>

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

  reply	other threads:[~2026-12-04 14:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 10:26 Pavee Zheng via B4 Relay
2026-12-04 14:16 ` Julian Braha [this message]
2026-12-04 17:22 ` Nicolas Schier
2026-12-04 17:33 ` Nicolas Schier

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=22852354-3a65-427a-a438-477a1b34d217@gmail.com \
    --to=julianbraha@gmail.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nathan@kernel.org \
    --cc=nsc@kernel.org \
    --cc=pavee.zheng@gmail.com \
    /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

all inboxes | Powered by JetHome®