-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Open
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
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
Metadata
Metadata
Assignees
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error