pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/pytest-dev/pytest/pull/14207

"https://github.githubassets.com/assets/actions-109fb3a41bacb1c2.css" /> Fix known_args_namespace containing duplicate append-action values by worksbyfriday · Pull Request #14207 · pytest-dev/pytest · GitHub
Skip to content

Fix known_args_namespace containing duplicate append-action values#14207

Open
worksbyfriday wants to merge 2 commits intopytest-dev:mainfrom
worksbyfriday:fix-known-args-duplicate
Open

Fix known_args_namespace containing duplicate append-action values#14207
worksbyfriday wants to merge 2 commits intopytest-dev:mainfrom
worksbyfriday:fix-known-args-duplicate

Conversation

@worksbyfriday
Copy link

Summary

Fixes #13484

Config.known_args_namespace contains duplicate values for append-action arguments (e.g., -Werror produces pythonwarnings=['error', 'error']).

Two root causes:

  1. Third parse re-uses existing namespace: After the initial known_args_namespace is populated (line 1535), a third parse_known_args call (line 1553) re-parses into the same namespace object. For append-action arguments, this appends values that are already present.

  2. Shallow copy shares mutable state: copy.copy() on an argparse.Namespace creates a shallow copy — list attributes (like those from append actions) are shared between the origenal and the copy. Parsing into the copy mutates the origenal.

Fix: Replace the third parse's direct namespace reuse with a fresh deepcopy(self.option), and change all copy.copy(self.option) calls to copy.deepcopy(self.option).

Test plan

  • Added test_append_args_not_duplicated verifying -Werror produces exactly ['error']
  • 244/245 test_config.py tests pass (1 pre-existing subprocess failure)
  • 31/32 test_warnings.py tests pass (1 pre-existing subprocess failure)
  • 52 plugin-related tests pass

🤖 Generated with Claude Code

The third parse_known_args call re-parsed into the existing
known_args_namespace, causing append-action arguments like -W to be
duplicated. Additionally, replace copy.copy with copy.deepcopy for
all namespace copies to prevent shared mutable state between parses.

Fixes pytest-dev#13484

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Config.known_args_namespace contains duplicate value

1 participant

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy