Skip to content

gh-136571: Convert more code in datetime to Argument Clinic #136573

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Doc/library/datetime.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2383,7 +2383,7 @@ locations where different offsets are used in different days of the year or
where historical changes have been made to civil time.


.. class:: timezone(offset, name=None)
.. class:: timezone(offset[, name])

The *offset* argument must be specified as a :class:`timedelta`
object representing the difference between the local time and UTC. It must
Expand Down
10 changes: 10 additions & 0 deletions Include/internal/pycore_global_objects_fini_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions Include/internal/pycore_global_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,9 @@ struct _Py_global_strings {
STRUCT_FOR_ID(d_parameter_type)
STRUCT_FOR_ID(data)
STRUCT_FOR_ID(database)
STRUCT_FOR_ID(date)
STRUCT_FOR_ID(day)
STRUCT_FOR_ID(days)
STRUCT_FOR_ID(debug)
STRUCT_FOR_ID(decode)
STRUCT_FOR_ID(decoder)
Expand Down Expand Up @@ -491,6 +493,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(hi)
STRUCT_FOR_ID(hook)
STRUCT_FOR_ID(hour)
STRUCT_FOR_ID(hours)
STRUCT_FOR_ID(id)
STRUCT_FOR_ID(ident)
STRUCT_FOR_ID(identity_hint)
Expand Down Expand Up @@ -586,8 +589,10 @@ struct _Py_global_strings {
STRUCT_FOR_ID(metadata)
STRUCT_FOR_ID(method)
STRUCT_FOR_ID(microsecond)
STRUCT_FOR_ID(microseconds)
STRUCT_FOR_ID(milliseconds)
STRUCT_FOR_ID(minute)
STRUCT_FOR_ID(minutes)
STRUCT_FOR_ID(mod)
STRUCT_FOR_ID(mode)
STRUCT_FOR_ID(module)
Expand Down Expand Up @@ -698,6 +703,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(scheduler)
STRUCT_FOR_ID(script)
STRUCT_FOR_ID(second)
STRUCT_FOR_ID(seconds)
STRUCT_FOR_ID(security_attributes)
STRUCT_FOR_ID(seek)
STRUCT_FOR_ID(seekable)
Expand Down Expand Up @@ -762,9 +768,12 @@ struct _Py_global_strings {
STRUCT_FOR_ID(text)
STRUCT_FOR_ID(threading)
STRUCT_FOR_ID(throw)
STRUCT_FOR_ID(time)
STRUCT_FOR_ID(timeout)
STRUCT_FOR_ID(timer)
STRUCT_FOR_ID(times)
STRUCT_FOR_ID(timespec)
STRUCT_FOR_ID(timestamp)
STRUCT_FOR_ID(timetuple)
STRUCT_FOR_ID(timeunit)
STRUCT_FOR_ID(top)
Expand Down Expand Up @@ -796,6 +805,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(wbits)
STRUCT_FOR_ID(week)
STRUCT_FOR_ID(weekday)
STRUCT_FOR_ID(weeks)
STRUCT_FOR_ID(which)
STRUCT_FOR_ID(who)
STRUCT_FOR_ID(withdata)
Expand Down
10 changes: 10 additions & 0 deletions Include/internal/pycore_runtime_init_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions Include/internal/pycore_unicodeobject_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions Lib/_pydatetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,7 @@ def fromisocalendar(cls, year, week, day):

@classmethod
def strptime(cls, date_string, format):
"""Parse a date string according to the given format (like time.strptime())."""
"""Parse string according to the given date format (like time.strptime())."""
import _strptime
return _strptime._strptime_datetime_date(cls, date_string, format)

Expand Down Expand Up @@ -1310,7 +1310,7 @@ def __reduce__(self):


class tzinfo:
"""Abstract base class for time zone info classes.
"""Abstract base class for time zone info objects.

Subclasses must override the tzname(), utcoffset() and dst() methods.
"""
Expand Down Expand Up @@ -1468,7 +1468,7 @@ def __new__(cls, hour=0, minute=0, second=0, microsecond=0, tzinfo=None, *, fold

@classmethod
def strptime(cls, date_string, format):
"""string, format -> new time parsed from a string (like time.strptime())."""
"""Parse string according to the given time format (like time.strptime())."""
import _strptime
return _strptime._strptime_datetime_time(cls, date_string, format)

Expand Down Expand Up @@ -1776,7 +1776,7 @@ def __reduce__(self):


class datetime(date):
"""datetime(year, month, day[, hour[, minute[, second[, microsecond[,tzinfo]]]]])
"""A combination of a date and a time.

The year, month and day arguments are required. tzinfo may be None, or an
instance of a tzinfo subclass. The remaining arguments may be ints.
Expand Down Expand Up @@ -2209,7 +2209,7 @@ def __str__(self):

@classmethod
def strptime(cls, date_string, format):
'string, format -> new datetime parsed from a string (like time.strptime()).'
"""Parse string according to the given date and time format (like time.strptime())."""
import _strptime
return _strptime._strptime_datetime_datetime(cls, date_string, format)

Expand Down Expand Up @@ -2435,6 +2435,8 @@ def _isoweek1monday(year):


class timezone(tzinfo):
"""Fixed offset from UTC implementation of tzinfo."""

__slots__ = '_offset', '_name'

# Sentinel value to disallow None
Expand Down
Loading
Loading