copy.replace loses slot-backed CSV dialect options
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 34/100
Hướng nghiên cứu
The report identifies Dialect.__replace__() and provides a reproducer, but names no source or test files. Start by locating that method and the CSV dialect tests, then reproduce the example on CPython 3.16. Done means copy.replace() preserves the slot-backed delimiter and both readers return [['alpha', 'beta']]; the reporter says they have already prepared a local fix and regression tests.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug report
copy.replace() loses slot-backed attributes of csv.Dialect subclasses. This can silently change how CSV data is parsed, even when the delimiter was not replaced.
Reproduced with CPython 3.16.0a1. The same implementation is present on main at 31a7d994a559a421814ca9e8edfcab21ae4a5b36.
import copy
import csv
class SemicolonDialect(csv.excel):
__slots__ = ('delimiter',)
def __init__(self):
self.delimiter = ';'
super().__init__()
dialect = SemicolonDialect()
replacement = copy.replace(dialect, quoting=csv.QUOTE_ALL)
print(list(csv.reader(['alpha;beta'], dialect)))
print(list(csv.reader(['alpha;beta'], replacement)))
Actual output:
[['alpha', 'beta']]
[['alpha;beta']]
Expected: both readers produce [['alpha', 'beta']], since only the quoting setting was replaced.
Dialect.__replace__() copies only __dict__, losing attributes stored in slots. The replacement therefore lacks its delimiter, and csv.reader falls back to the default comma delimiter.
I have prepared a local fix and regression tests.
CPython versions tested on:
3.16
Operating systems tested on:
No response
- Ngôn ngữ chính
- Python
- Star
- 77.7k
- Fork
- 38.3k
- Merge trung bình
- 12 giờ 27 phút
- Pull request đã merge (30 ngày)
- 710
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của python/cpython
-
3.16 build type-bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
python/cpython#160829 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
dependencies infra topic-ensurepip
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 1 ngày
-
symtable: repr() of a Symbol raises TypeError under -X lazy_imports=allCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởstdlib topic-lazy-imports type-bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
python/cpython#160810 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
tarfile: extractfile(member).read() of a sparse member is slow due to repeated bytes concatenationĐang mởperformance stdlib triaged type-bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
python/cpython#160774 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
tests topic-profiling type-bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
python/cpython#160334 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của python/cpython
Issue tương tự
-
area/profiles comp/cli P3 type/feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
NousResearch/hermes-agent#146372 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[oblt-aw][autodoc] Document obs-aw-automerge contract and fix automerge doc inconsistenciesCó thể đã có người làm @github-actions đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
GeoSeries scale and skew tests fail with pytest 9.2.0Có thể đã có người làm @jiayuasu đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
admission-deferred priority: medium status: ready work-class: scoped
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
melodic-software/claude-code-plugins#10887 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày