Skip to content

Commit 1d65305

Browse files
committed
Update error for offset arg in timezone
1 parent 4363e9e commit 1d65305

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

Lib/_pydatetime.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ def _check_utc_offset(name, offset):
563563
if not -timedelta(1) < offset < timedelta(1):
564564
raise ValueError("offset must be a timedelta "
565565
"strictly between -timedelta(hours=24) and "
566-
f"timedelta(hours=24), not {offset.__repr__()}")
566+
"timedelta(hours=24)")
567567

568568
def _check_date_fields(year, month, day):
569569
year = _index(year)
@@ -2419,7 +2419,7 @@ def __new__(cls, offset, name=_Omitted):
24192419
if not cls._minoffset <= offset <= cls._maxoffset:
24202420
raise ValueError("offset must be a timedelta "
24212421
"strictly between -timedelta(hours=24) and "
2422-
f"timedelta(hours=24), not {offset.__repr__()}")
2422+
"timedelta(hours=24)")
24232423
return cls._create(offset, name)
24242424

24252425
def __init_subclass__(cls):

Modules/_datetimemodule.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,8 +1440,7 @@ new_timezone(PyObject *offset, PyObject *name)
14401440
GET_TD_DAYS(offset) < -1 || GET_TD_DAYS(offset) >= 1) {
14411441
PyErr_Format(PyExc_ValueError, "offset must be a timedelta"
14421442
" strictly between -timedelta(hours=24) and"
1443-
" timedelta(hours=24),"
1444-
" not %R", offset);
1443+
" timedelta(hours=24)");
14451444
return NULL;
14461445
}
14471446

@@ -1513,8 +1512,7 @@ call_tzinfo_method(PyObject *tzinfo, const char *name, PyObject *tzinfoarg)
15131512
Py_DECREF(offset);
15141513
PyErr_Format(PyExc_ValueError, "offset must be a timedelta"
15151514
" strictly between -timedelta(hours=24) and"
1516-
" timedelta(hours=24),"
1517-
" not %R", offset);
1515+
" timedelta(hours=24)");
15181516
return NULL;
15191517
}
15201518
}

0 commit comments

Comments
 (0)