Fwd: timedelta object recursion bug

Ben Hirsig iamgusi at gmail.com
Thu Jul 28 05:54:54 EDT 2022


Hi, I noticed this when using the requests library in the response.elapsed
object (type timedelta). Tested using the standard datetime library alone
with the example displayed on
https://docs.python.org/3/library/datetime.html#examples-of-usage-timedelta



It appears as though the timedelta object recursively adds its own
attributes (min, max, resolution) as further timedelta objects. I’m not
sure how deep they go, but presumably hitting the recursion limit.



>from datetime import timedelta

>year = timedelta(days=365)

>print(year.max)

  999999999 days, 23:59:59.999999

>print(year.max.min.max.resolution.max.min)

  -999999999 days, 0:00:00



I’m using 3.10.3



Cheers


More information about the Python-list mailing list