Constructor. Arguments: year, month, day (required, base 1)
(cls, year, month=None, day=None)
| 979 | __slots__ = '_year', '_month', '_day', '_hashcode' |
| 980 | |
| 981 | def __new__(cls, year, month=None, day=None): |
| 982 | """Constructor. |
| 983 | |
| 984 | Arguments: |
| 985 | |
| 986 | year, month, day (required, base 1) |
| 987 | """ |
| 988 | if (month is None and |
| 989 | isinstance(year, (bytes, str)) and len(year) == 4 and |
| 990 | 1 <= ord(year[2:3]) <= 12): |
| 991 | # Pickle support |
| 992 | if isinstance(year, str): |
| 993 | try: |
| 994 | year = year.encode('latin1') |
| 995 | except UnicodeEncodeError: |
| 996 | # More informative error message. |
| 997 | raise ValueError( |
| 998 | "Failed to encode latin1 string when unpickling " |
| 999 | "a date object. " |
| 1000 | "pickle.load(data, encoding='latin1') is assumed.") |
| 1001 | self = object.__new__(cls) |
| 1002 | self.__setstate(year) |
| 1003 | self._hashcode = -1 |
| 1004 | return self |
| 1005 | year, month, day = _check_date_fields(year, month, day) |
| 1006 | self = object.__new__(cls) |
| 1007 | self._year = year |
| 1008 | self._month = month |
| 1009 | self._day = day |
| 1010 | self._hashcode = -1 |
| 1011 | return self |
| 1012 | |
| 1013 | # Additional constructors |
| 1014 |
no test coverage detected