Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There may be a bug or vulnerability in the assignment of a List here #120404

Closed
KiloMaster opened this issue Jun 12, 2024 · 1 comment
Closed

Comments

@KiloMaster
Copy link

KiloMaster commented Jun 12, 2024

Bug report

Bug description:

Here is the case ; when i assign value to list, things is out of my control.
when i just assign value to a[2][1], Assignment of list happend on other index.
I don't know if the design is like this or if there are bugs or vulnerabilities here.

In China, my email cannot be reached security@python.com. If there are security issues, please help me contact and forward relevant information to the security team.

# Add a code block here, if required
import sys
print(sys.version)
#3.6.8 (default, Nov 14 2023, 16:29:52)
#[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
a=[[0,0]]*6
print(a)
#[[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]
a[1]=[1,1]
print(a)
#[[0, 0], [1, 1], [0, 0], [0, 0], [0, 0], [0, 0]]
a[2][1]=2
print(a)
#[[0, 2], [1, 1], [0, 2], [0, 2], [0, 2], [0, 2]]

图片

CPython versions tested on:

3.8

Operating systems tested on:

Linux

@KiloMaster KiloMaster added the type-bug An unexpected behavior, bug, or error label Jun 12, 2024
@Eclips4
Copy link
Member

Eclips4 commented Jun 12, 2024

Hello!
This is intended behavior, see https://docs.python.org/3/faq/programming.html#how-do-i-create-a-multidimensional-list for more information.

@Eclips4 Eclips4 closed this as not planned Won't fix, can't repro, duplicate, stale Jun 12, 2024
@Eclips4 Eclips4 removed the type-bug An unexpected behavior, bug, or error label Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants