Strange 3.14.0a1 problem in attribute assignment
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
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
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
首先,使用 reportlab 的 src/reportlab/platypus/paraparser.py 第 3131 行附近的程式碼以及 src/reportlab/lib/abag.py,在 Python 3.14 和較早版本上重現報告中的行為。比較屬性指派行為,並判斷該報告是否記錄了 CPython 回歸;完成的標準是找出原因並記錄或實作適當的解決方案。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- backend
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 需要釐清
- 新手友好度
- 25/100