python / python/cpython

Strange 3.14.0a1 problem in attribute assignment

Open
#125,968 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported behavior on Python 3.14 and an earlier version using reportlab's src/reportlab/platypus/paraparser.py around line 3131 and src/reportlab/lib/abag.py. Compare the attribute assignment behavior and determine whether the report documents a CPython regression; done means identifying the cause and recording or implementing an appropriate resolution.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.