[New-bugs-announce] [issue37032] Add CodeType.replace() method

STINNER Victor report at bugs.python.org
Fri May 24 05:25:55 EDT 2019


New submission from STINNER Victor <vstinner at redhat.com>:

Each type types.CodeType constructor changes, a lot of applications break. Python 3.8 added a new parameter which broke for example the Genshi project, just to name one.

I propose to add a new CodeType.replace() method, similar to datetime.datetime.replace and namedtuple._replace() for example:

$ python3
Python 3.7.3 (default, Mar 27 2019, 13:41:07) 

>>> import datetime
>>> d=datetime.datetime.now()
>>> d2=d.replace(year=2010)
>>> d, d2
(datetime.datetime(2019, 5, 24, 11, 25, 3, 839966), datetime.datetime(2010, 5, 24, 11, 25, 3, 839966))

>>> import collections
>>> Point = collections.namedtuple("Point", "x y")
>>> p=Point(1, 2)
>>> p2=p._replace(y=3)
>>> p, p2
(Point(x=1, y=2), Point(x=1, y=3))

----------
components: Interpreter Core
messages: 343360
nosy: pablogsal, vstinner
priority: normal
severity: normal
status: open
title: Add CodeType.replace() method
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37032>
_______________________________________


More information about the New-bugs-announce mailing list