python / python/cpython

Accidental name bindings with structural pattern matching

Đang mở
#93,059 7 bình luận 2 reaction 1 người được giao Xem trên GitHub

@brandtbucher đang làm issue này rồi.

Từ ngày 22/5/2022.

interpreter-core type-bug
Ngôn ngữ chính
Python
Star
77.2k
Fork
36k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

Bug report

Your environment

  • CPython versions tested on: 3.10.2, 3.11.0a6
  • Operating system and architecture: macOS Monterey, Version 12.3.1. Mac mini running M1, Apple silicon.

Steps to reproduce:

Run the code in bug.py, attached.

bug.zip

The output on my Mac mini is:

% python bug.py
Cheese Sandwich

Search for 'match' in the code. Notice that one of the terms matches
the only str in the list, "Cheese Sandwich". Later we create a dataclass
of type PersonHeight. On the last line of the file, we print the type
of one of the fields in a PersonHeight object. Note that it is not <class 'str'> as it should be,
but "Cheese Sandwich"

If we comment out the match expression, we get the correct behavior
(see comment below in code)

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.