python / python/cpython

Strange 3.14.0a1 problem in attribute assignment

Đang mở
#125,968 9 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

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

Mô tả

Bug report

Bug description:
		# bold, italic
		_ = tt2ps(frag.fontName,frag.bold,frag.italic)
		if _=='helvetica': breakpoint()
		frag.fontName = _
		if frag.fontName=='helvetica': breakpoint()

the code above breaks at the second breakpoint. The value of _ is 'Helvetica', but the attribute value is 'helvetica' (the original value). It's not clear if the assignment is carried out or somehow transformed to lower case. The frag class is ParaFrag(ABag): pass with ABag defined as

class ABag:
	"""
	'Attribute Bag' - a trivial BAG class for holding attributes.

	This predates modern Python.  Doing this again, we'd use a subclass
	of dict.

	You may initialize with keyword arguments.
	a = ABag(k0=v0,....,kx=vx,....) ==> getattr(a,'kx')==vx

	c = a.clone(ak0=av0,.....) copy with optional additional attributes.
	"""
	def __init__(self,**attr):
		self.__dict__.update(attr)

	def clone(self,**attr):
		n = self.__class__(**self.__dict__)
		if attr: n.__dict__.update(attr)
		return n

	def __repr__(self):
		D = self.__dict__
		K = list(D.keys())
		K.sort()
		return '%s(%s)' % (self.__class__.__name__,', '.join(['%s=%r' % (k,D[k]) for k in K]))

the _ intermediate variable is not actually used in the original code, but the original and this code works as expected in python 3.9-3.13.

Original code is https://hg.reportlab.com/hg-public/reportlab/file/tip/src/reportlab/platypus/paraparser.py (line 3131) and https://hg.reportlab.com/hg-public/reportlab/file/tip/src/reportlab/lib/abag.py

CPython versions tested on:

3.14

Operating systems tested on:

Linux

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.

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện hành vi được báo cáo trên Python 3.14 và một phiên bản trước đó, sử dụng src/reportlab/platypus/paraparser.py của reportlab quanh dòng 3131 và src/reportlab/lib/abag.py. So sánh hành vi gán thuộc tính và xác định liệu báo cáo có ghi nhận một hồi quy của CPython hay không; được xem là hoàn tất khi đã xác định nguyên nhân và ghi lại hoặc triển khai một giải pháp phù hợp.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
backend
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/100

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.