On Thu, Aug 27, 2015 at 8:13 AM, Ethan Furman <ethan@stoneleaf.us> wrote:
[Alexander Belopolsky]
>>
>>
>> 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:

[Ethan Furman]
datetime.__new__         YES
datetime.combine         YES (could have a time instance with fold=None)
datetime.replace         YES
datetime.strptime        only if `fold=` is allowed

[Ethan Furman]
>
> 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/.

I don't grasp the significance of the slashes in your text above, but it looks like your idea is similar to the one I outlined in the "Strict Invalid Time Checking: an idea for another PEP" thread.

As I said there, it is workable, but there are many details that need to be thought out before this idea becomes PEP-worthy.  Let's move the discussion of those details to a thread that does not have PEP 495 in the subject.  Feel free to reuse my thread or open a new one.

What we can do in PEP 495 is tighten the language about acceptable values for the fold= argument in replace().  Since pure python implementation currently allows None for year through microsecond arguments, we have the following text in the PEP:

"""
 In CPython, any non-integer value of fold [passed to replace()] will raise a TypeError , but other implementations may allow the value None to behave the same as when fold is not given.
"""

I am fine with removing this text and leaving fold=None option open for the future PEPs to explore.