Opened 47 minutes ago
Last modified 37 minutes ago
#36759 new Bug
Fixed variable shadowing in ValidationError.__init__()
| Reported by: | Mohit Sharma | Owned by: | |
|---|---|---|---|
| Component: | Core (Other) | Version: | dev |
| Severity: | Normal | Keywords: | variable-shadowing ValidationError exceptions |
| Cc: | Mohit Sharma | Triage Stage: | Unreviewed |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | yes | UI/UX: | no |
Description
Problem
The ValidationError.__init__() method has a variable shadowing bug in the list processing branch. The loop variable message shadows the function parameter message, which can cause issues when processing lists of validation errors.
Location
django/core/exceptions.py, line 175
Current Code
for message in message: # Variable shadowing!== Solution ==
Rename the loop variable from message to item to avoid shadowing the function parameter.
Patch
I have a patch ready with:
- Fix: Renamed loop variable to
item - Test: Added comprehensive test
test_list_input_processes_all_items() - All existing tests pass
Branch
Branch: ticket_12345
PR: [Will add PR link after creating]
Solution
Rename the loop variable from message to item to avoid shadowing the function parameter.
Patch
I have a patch ready with:
Fix: Renamed loop variable to item
Test: Added comprehensive test test_list_input_processes_all_items()
All existing tests pass
Branch
Branch: ticket_12345
PR: [Will add PR link after creating]
Pull request created: https://github.com/django/django/pull/20347