| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
| |
Previously, calling the strftime() method on a datetime object with a
trailing '%' in the format string would result in an exception. However,
this only occured when the datetime C module was being used; the python
implementation did not match this behavior. Datetime is now PEP-399
compliant, and will not throw an exception on a trailing '%'.
(cherry picked from commit 454b3d4ea246e8751534e105548d141ed7b0b032)
Co-authored-by: MichaelSaah <mike.saah@gmail.com>
|
|
|
|
|
|
|
| |
Python 2. (GH-11017) (GH-11022)
encoding='latin1' should be used for successful decoding.
(cherry picked from commit 8452ca15f41061c8a6297d7956df22ab476d4df4)
|
|
|
|
|
|
|
|
|
|
|
| |
Fixes assertion failures in _datetimemodule.c
introduced in the previous fix (see bpo-31752).
Rather of trying to handle an int subclass as exact int,
let it to use overridden special methods, but check the
result of divmod().
(cherry picked from commit 3ec0f495163da3b7a15deb2805cec48aed432f58)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
(GH-10284)
Two kind of mistakes:
1. Missed space. After concatenating there is no space between words.
2. Missed comma. Causes unintentional concatenating in a list of strings.
(cherry picked from commit 34fd4c20198dea6ab2fe8dc6d32d744d9bde868d)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Use _PyUnicode_Copy in sanitize_isoformat_str
* Use repr in fromisoformat error message
This reverses commit 67b74a98b2 per Serhiy Storchaka's suggestion:
I suggested to use %R in the error message because including the raw
string can be confusing in the case of empty string, or string
containing trailing whitespaces, invisible or unprintable characters.
We agree that it is better to change both the C and pure Python versions
to use repr.
* Retain non-sanitized dtstr for error printing
This does not create an extra string, it just holds on to a reference to
the original input string for purposes of creating the error message.
* PEP 7 fixes to from_isoformat
* Separate handling of Unicode and other errors
In the initial implementation, errors other than encoding errors would
both raise an error indicating an invalid format, which would not be
true for errors like MemoryError.
* Drop needs_decref from _sanitize_isoformat_str
Instead _sanitize_isoformat_str returns a new reference, even to the
original string.
(cherry picked from commit 3df85404d4bf420db3362eeae1345f2cad948a71)
Co-authored-by: Paul Ganssle <pganssle@users.noreply.github.com>
|
|
|
|
|
| |
(cherry picked from commit d6a61f232619f8a8e6efacc3da5a02abaf25f090)
Co-authored-by: Chris Barker <Chris.Barker@noaa.gov>
|
|
|
|
|
|
|
|
| |
tzinfo_from_isoformat_results. (GH-8869)
Reported by Svace static analyzer.
(cherry picked from commit 498845368ff0f6238750ab1d443e7cf4ec98ccd2)
Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
code points (GH-8862)
The current C implementations **crash** if the input includes a surrogate
Unicode code point, which is not possible to encode in UTF-8.
Important notes:
1. It is possible to pass a non-UTF-8 string as a separator to the
`.isoformat()` methods.
2. The pure-Python `datetime.fromisoformat()` implementation accepts
strings with a surrogate as the separator.
In `datetime.fromisoformat()`, in the special case of non-UTF-8 separators,
this implementation will take a performance hit by making a copy of the
input string and replacing the separator with 'T'.
Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
Co-authored-by: Paul Ganssle <paul@ganssle.io>
(cherry picked from commit 096329f0b2bf5e3f0a16363aa631d993ce078737)
Co-authored-by: Paul Ganssle <pganssle@users.noreply.github.com>
|
|
|
|
|
|
|
|
| |
(GH-2385) (GH-8466)
On Windows, passing a negative value to local results in an OSError because localtime_s on Windows does not support negative timestamps. Unfortunately this means that fold detection for timestamps between 0 and max_fold_seconds will result in this OSError since we subtract max_fold_seconds from the timestamp to detect a fold. However, since we know there haven't been any folds in the interval [0, max_fold_seconds) in any timezone, we can hackily just forego fold detection for this time range on Windows.
(cherry picked from commit 96d1e69a12ed8ab80203277e1abdaf573457a964)
Co-authored-by: Ammar Askar <ammar_askar@hotmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A datetime object d is aware if d.tzinfo is not None and
d.tzinfo.utcoffset(d) does not return None. If d.tzinfo is None,
or if d.tzinfo is not None but d.tzinfo.utcoffset(d) returns None,
d is naive.
This commit ensures that instances with non-None d.tzinfo, but
d.tzinfo.utcoffset(d) returning None are treated as naive.
In addition, C acceleration code will raise TypeError if
d.tzinfo.utcoffset(d) returns an object with the type other than
timedelta.
* Updated the documentation.
Assume that the term "naive" is defined elsewhere and remove the
not entirely correct clarification. Thanks, Tim.
(cherry picked from commit 877b23202b7e7d4f57b58504fd0eb886e8c0b377)
Co-authored-by: Alexander Belopolsky <abalkin@users.noreply.github.com>
|
|
|
|
|
| |
Most of them have been added in 3.7.
(cherry picked from commit bac2d5ba30339298db7d4caa9c8cd31d807cf081)
|
|
|
|
|
|
| |
Fix typos found by codespell in docs, docstrings, and comments.
(cherry picked from commit c3d9508ff22ece9a96892b628dd5813e2fb0cd80)
Co-authored-by: Leo Arias <leo.arias@canonical.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Add timezone to datetime C API
* Add documentation for timezone C API macros
* Add dedicated tests for datetime type check macros
* Remove superfluous C API test
* Drop support for TimeZoneType in datetime C API
* Expose UTC singleton to the datetime C API
* Update datetime C-API documentation to include links
* Add reference count information for timezone constructors
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Add tests for date subclass alternate constructors
* Switch over alternate date constructors to fast path
* Switch datetime constructors to fastpath, fix bpo-32404
* Add fast path for datetime in date subclass constructor
* Set fold in constructor in datetime.combine
* Add news entries.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Modify locale.localeconv(), time.tzname, os.strerror() and other
functions to ignore the UTF-8 Mode: always use the current locale
encoding.
Changes:
* Add _Py_DecodeLocaleEx() and _Py_EncodeLocaleEx(). On decoding or
encoding error, they return the position of the error and an error
message which are used to raise Unicode errors in
PyUnicode_DecodeLocale() and PyUnicode_EncodeLocale().
* Replace _Py_DecodeCurrentLocale() with _Py_DecodeLocaleEx().
* PyUnicode_DecodeLocale() now uses _Py_DecodeLocaleEx() for all
cases, especially for the strict error handler.
* Add _Py_DecodeUTF8Ex(): return more information on decoding error
and supports the strict error handler.
* Rename _Py_EncodeUTF8_surrogateescape() to _Py_EncodeUTF8Ex().
* Replace _Py_EncodeCurrentLocale() with _Py_EncodeLocaleEx().
* Ignore the UTF-8 mode to encode/decode localeconv(), strerror()
and time zone name.
* Remove PyUnicode_DecodeLocale(), PyUnicode_DecodeLocaleAndSize()
and PyUnicode_EncodeLocale() now ignore the UTF-8 mode: always use
the "current" locale.
* Remove _PyUnicode_DecodeCurrentLocale(),
_PyUnicode_DecodeCurrentLocaleAndSize() and
_PyUnicode_EncodeCurrentLocale().
|
|
|
| |
Closes bpo-15873.
|
|
|
|
| |
functions (GH-793)
|
|
|
|
|
| |
integers. (#3947)
Bad remainder in divmod() in intermediate calculations caused an assertion failure.
|
|
|
| |
Implementations of these operations are virtually identical.
|
|
|
|
| |
bad as_integer_ratio() method. (#3227)
|
|
|
|
|
|
|
| |
* Add Py_UNREACHABLE() as an alias to abort().
* Use Py_UNREACHABLE() instead of assert(0)
* Convert more unreachable code to use Py_UNREACHABLE()
* Document Py_UNREACHABLE() and a few other macros.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Closes issue bpo-5288: Allow tzinfo objects with sub-minute offsets.
* bpo-5288: Implemented %z formatting of sub-minute offsets.
* bpo-5288: Removed mentions of the whole minute limitation on TZ offsets.
* bpo-5288: Removed one more mention of the whole minute limitation.
Thanks @csabella!
* Fix a formatting error in the docs
* Addressed review comments.
Thanks, @haypo.
|
| |
|
|
|
| |
objects when pass out of bound fold argument.
|
| |
|
|\ |
|
| |
| |
| |
| |
| | |
Issue #29100: Fix datetime.fromtimestamp() regression introduced in Python
3.6.0: check minimum and maximum years.
|
|\ \
| |/ |
|
| |
| |
| |
| |
| |
| | |
Fix time_hash() function: replace DATE_xxx() macros with TIME_xxx() macros.
Before, the hash function used a wrong value for microseconds if fold is set
(equal to 1).
|
| |
| |
| |
| | |
dict.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Issue #28915: Replace _PyObject_CallMethodId() with
_PyObject_CallMethodIdObjArgs() when the format string was only made of "O"
formats, PyObject* arguments.
_PyObject_CallMethodIdObjArgs() avoids the creation of a temporary tuple and
doesn't have to parse a format string.
|
| |
| |
| |
| | |
Issue #28915.
|
| |
| |
| |
| |
| |
| | |
Issue #28915: Avoid calling _PyObject_CallMethodId() with "(...)" format to
avoid the creation of a temporary tuple: use Py_BuildValue() with
_PyObject_CallMethodIdObjArgs().
|
| |
| |
| |
| |
| | |
Issue #28915: Without parenthesis, _PyObject_CallMethodId() avoids the creation
a temporary tuple, and so is more efficient.
|
|\ \
| |/ |
|
| | |
|
|\ \
| |/
| |
| | |
with PyUnicode_AsUTF8 and PyUnicode_AsUTF8AndSize.
|
| |
| |
| |
| | |
with PyUnicode_AsUTF8 and PyUnicode_AsUTF8AndSize.
|
|/ |
|
|
|
|
|
|
| |
Introduced platform independent _PyTime_localtime API that is similar
to POSIX localtime_r, but available on all platforms. Patch by Ed
Schouten.
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
Don't pass "()" format to PyObject_CallXXX() to call a function without
argument: pass NULL as the format string instead. It avoids to have to parse a
string to produce 0 argument.
|
| |
|
| |
|
| |
|