Skip to content
This repository was archived by the owner on Oct 2, 2023. It is now read-only.

Commit 85f8f6e

Browse files
committed
Converter now checks if the entered numbers are too large to b processed
1 parent 4ce3870 commit 85f8f6e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

PyDrocsid/converter.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,12 @@ async def convert(self, ctx: Context[Bot], argument: str) -> int | None:
7979
0 if (value := match.group(i)) is None else int(value[:-1]) for i in range(1, 7)
8080
]
8181

82-
rd = relativedelta(years=years, months=months, weeks=weeks, days=days)
83-
td = timedelta(days=rd.days, hours=hours, minutes=minutes)
82+
if any(unit_value >= (1 << 31) for unit_value in (years, months, weeks, days, hours, minutes)):
83+
raise BadArgument(t.invalid_duration_inf)
84+
85+
days += years * 365
86+
days += months * 30
87+
td = timedelta(weeks=weeks, days=days, hours=hours, minutes=minutes)
8488
duration = int(td.total_seconds() / 60)
8589

8690
if duration <= 0:

0 commit comments

Comments
 (0)