[Datetime-SIG] PEP-495 - Strict Invalid Time Checking
Ethan Furman
ethan at stoneleaf.us
Thu Aug 27 14:13:22 CEST 2015
On 08/25/2015 02:22 PM, Alexander Belopolsky wrote:
> On Tue, Aug 25, 2015 at 5:04 PM, Carl Meyer wrote:
>>
>> I can't imagine how raising an exception on invalid times only if a
>> non-default sentinel value is given for a flag that is _new in PEP 495_
>> could possibly break 4000 lines of existing datetime tests.
>
> OK, so datetime module itself will never set fold=-1. In the list below, can you mark the methods that need to be patched to check the fold attribute in your preferred design:
If `fold=None` is present /when attempting to create a datetime/ that is ambiguous or invalid, an exception is raised /at that moment/ meaning that a datetime with `fold=None` /will never exist/.
`fold=None` /will not be the default/.
> datetime.__add__ no
> datetime.__eq__ no
> datetime.__format__ no
> datetime.__ge__ no
> datetime.__gt__ no
> datetime.__hash__ no
> datetime.__le__ no
> datetime.__lt__ no
> datetime.__ne__ no
> datetime.__new__ YES
> datetime.__radd__ no
> datetime.__reduce__ no
> datetime.__reduce_ex__ no
> datetime.__repr__ no
> datetime.__rsub__ no
> datetime.__str__ no
> datetime.astimezone no
> datetime.combine YES (could have a time instance with fold=None)
> datetime.ctime no
> datetime.date no
> datetime.dst no
> datetime.fromordinal no
> datetime.fromtimestamp no
> datetime.isocalendar no
> datetime.isoformat no
> datetime.isoweekday no
> datetime.now no
> datetime.replace YES
> datetime.strftime no
> datetime.strptime only if `fold=` is allowed
> datetime.time no
> datetime.timestamp no
> datetime.timetuple no
> datetime.timetz no
> datetime.today no
> datetime.toordinal no
> datetime.tzname no
> datetime.utcfromtimestamp no
> datetime.utcnow no
> datetime.utcoffset no
> datetime.utctimetuple no
> datetime.weekday no
--
~Ethan~
More information about the Datetime-SIG
mailing list