pganssle / zoneinfo

Reference implementation for the proposed standard library module zoneinfo
Other
51 stars 20 forks source link

Decrement the refcount of PyLong_FromLong(1) in the correct branch #97

Closed pablogsal closed 3 years ago

pablogsal commented 3 years ago

See https://bugs.python.org/issue42697 for more info

pablogsal commented 3 years ago

CC: @pganssle

pganssle commented 3 years ago

Here is an MWE of the issue:

from backports.zoneinfo import ZoneInfo
from datetime import datetime, timezone

class SubDT(datetime):
    pass

LON = ZoneInfo("Europe/London")
d = SubDT(2020, 10, 25, 1, 30, tzinfo=timezone.utc)

# Each pass through the loop inappropriately reduces the reference count on the
# `1` object by 1. Since there are usually a large number of live references to
# `1`, this won't have any immediate noticeable effect unless you do it a lot.
for i in range(10000):
    d.astimezone(LON)