summaryrefslogtreecommitdiff
path: root/django/utils
Commit message (Collapse)AuthorAgeFilesLines
* Fixed #34515 -- Made LocaleMiddleware prefer language from paths when i18n ↵Mariusz Felisiak2023-05-023-3/+6
| | | | | | | | | | | | | | patterns are used. Regression in 94e7f471c4edef845a4fe5e3160132997b4cca81. This reverts commit 94e7f471c4edef845a4fe5e3160132997b4cca81 (refs #34069) and partly reverts commit 3b4728310a7a64f8fcc548163b0aa5f98a5c78f5. Thanks Anthony Baillard for the report. Co-Authored-By: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com>
* Corrected exception type in safe_join()'s docstring.David Sanders2023-04-201-2/+2
|
* Refs #34483 -- Fixed timesince()/timeuntil() with timezone-aware dates on ↵Mariusz Felisiak2023-04-141-3/+6
| | | | | | different days and interval less than 1 day. Follow up to 813015d67e2557fa859a07930a9becec4e5f64a0. Regression in 8d67e16493c903adc9d049141028bc0fff43f8c8.
* Fixed #34483 -- Fixed timesince()/timeuntil() with timezone-aware dates and ↵nessita2023-04-131-1/+2
| | | | | | | interval less than 1 day. Regression in 8d67e16493c903adc9d049141028bc0fff43f8c8. Thanks Lorenzo Peña for the report.
* Fixed #34455 -- Restored i18n_patterns() respect of prefix_default_language ↵sarahboyce2023-04-101-0/+1
| | | | | | | | argument when fallback language is used. Regression in 94e7f471c4edef845a4fe5e3160132997b4cca81. Thanks Oussama Jarrousse for the report.
* Refs #34118 -- Fixed CustomChoicesTests.test_uuid_unsupported on Python 3.12+.Mariusz Felisiak2023-04-051-0/+1
| | | https://github.com/python/cpython/commit/2a4d8c0a9e88f45047da640ce5a92b304d2d39b1
* Fixed #34445 -- Fixed string-casting of non-string lazy objects.Ran Benita2023-03-301-8/+2
| | | | | | | | This removes __text_cast() as it's the same as __cast(). _delegate_bytes and __delegate_text are mutually exclusive so the `if self._delegate_bytes` branch in __cast() is unreachable. Co-Authored-By: David Sanders <shang.xiao.sanders@gmail.com>
* Removed unused __bytes_cast_encoded() from proxy class in lazy().Ran Benita2023-03-301-3/+0
| | | | Unused since c716fe87821df00f9f03ecc761c914d1682591a2.
* Refs #33476 -- Applied Black's 2023 stable style.David Smith2023-02-013-2/+2
| | | | | | | | Black 23.1.0 is released which, as the first release of the year, introduces the 2023 stable style. This incorporates most of last year's preview style. https://github.com/psf/black/releases/tag/23.1.0
* Fixed CVE-2023-23969 -- Prevented DoS with pathological values for ↵Nick Pope2023-02-011-1/+30
| | | | | | | | | | | | Accept-Language. The parsed values of Accept-Language headers are cached in order to avoid repetitive parsing. This leads to a potential denial-of-service vector via excessive memory usage if the raw value of Accept-Language headers is very large. Accept-Language headers are now limited to a maximum length in order to avoid this issue.
* Fixed #32528 -- Replaced django.utils.topological_sort with ↵Nick Pope2023-01-191-42/+0
| | | | | | graphlib.TopologicalSort(). graphlib.TopologicalSort() is available since Python 3.9.
* Refs #34233 -- Used str.removeprefix()/removesuffix().Mariusz Felisiak2023-01-183-5/+4
|
* Refs #34233 -- Used types.NoneType.Nick Pope2023-01-181-1/+2
| | | Available since Python 3.10 where it was reintroduced.
* Refs #34233 -- Referenced isocalendar() results by names not indexes.Mariusz Felisiak2023-01-181-2/+2
| | | isocalendar() returns a namedtuple() instead of tuple in Python 3.9+
* Fixed #34233 -- Dropped support for Python 3.8 and 3.9.Mariusz Felisiak2023-01-185-126/+5
|
* Advanced deprecation warnings for Django 5.0.Mariusz Felisiak2023-01-171-4/+4
|
* Refs #32365 -- Removed django.utils.timezone.utc per deprecation timeline.Mariusz Felisiak2023-01-171-26/+1
|
* Refs #30127 -- Removed name argument for ↵Mariusz Felisiak2023-01-171-11/+1
| | | | | | django.utils.functional.cached_property(). Per deprecation timeline.
* Refs #32365 -- Removed is_dst argument for various methods and functions.Mariusz Felisiak2023-01-171-13/+1
| | | | Per deprecation timeline.
* Refs #32365 -- Removed support for pytz timezones per deprecation timeline.Mariusz Felisiak2023-01-171-66/+6
|
* Refs #32873 -- Removed settings.USE_L10N per deprecation timeline.Mariusz Felisiak2023-01-172-16/+10
|
* Refs #32738 -- Removed django.utils.datetime_safe module per deprecation ↵Mariusz Felisiak2023-01-171-118/+0
| | | | timeline.
* Refs #32712 -- Removed django.utils.baseconv module per deprecation timeline.Mariusz Felisiak2023-01-171-115/+0
|
* Refs #33879 -- Fixed plural value deprecation warnings.Mariusz Felisiak2023-01-111-1/+1
| | | | | Plural value must be an integer. Regression in 8d67e16493c903adc9d049141028bc0fff43f8c8.
* Fixed #34243 -- Fixed timesince() crash with timezone-aware dates and ↵sag᠎e2023-01-051-0/+1
| | | | | interval longer than 1 month. Regression in 8d67e16493c903adc9d049141028bc0fff43f8c8.
* Simplified handling ambiguous/imaginary datetimes in django.utils.dateformat.Nick Pope2023-01-051-15/+11
| | | | | | | Instead of the separate property, we can just not set self.timezone if the datetime is ambiguous or imaginary. This ensures that this check will only ever happen once as it's dependant on the datetime object and not the format string characters.
* Added support for datetime.date to DateFormat.r().Nick Pope2023-01-051-10/+8
|
* Simplified django.utils.dateformat.DateFormat.O()/t()/e() a bit.Nick Pope2023-01-051-3/+4
| | | | | | | | | | | O() - we should try to avoid calling specifier methods from each other to avoid extra function call overhead. In addition we end up, in this case, duplicating the ambiguous/imaginary datetime checks. We're also going to be looking at simplifying things by having all of these specifier methods return strings and not an random mix of types. t() - the value can only be one of 28, 29, 30, or 31. As such, there is no need to zero-pad to a width of two.
* Optimized imports in django.utils.dateformat.Nick Pope2023-01-051-8/+8
| | | | | Avoid extra attribute lookup in specifier methods, etc. by importing classes from datetime directly.
* Simplified django.utils.formats.date_format()/time_format() calls.Nick Pope2023-01-041-1/+1
| | | | | This removes redundant get_format() calls and passing a default value for the format argument.
* Fixed #33879 -- Improved timesince handling of long intervals.GianpaoloBranca2023-01-041-32/+68
|
* Fixed #33735 -- Added async support to StreamingHttpResponse.Carlton Gibson2022-12-221-0/+25
| | | | | Thanks to Florian Vazelle for initial exploratory work, and to Nick Pope and Mariusz Felisiak for review.
* Refs #34118 -- Adopted asgiref coroutine detection shims.Carlton Gibson2022-12-201-7/+4
| | | Thanks to Mariusz Felisiak for review.
* Fixed #34170 -- Implemented Heal The Breach (HTB) in GzipMiddleware.Andreas Pelme2022-12-171-4/+24
|
* Fixed #34194 -- Added django.utils.http.content_disposition_header().Alex Vandiver2022-12-051-0/+22
|
* Updated documentation and comments for RFC updates.Nick Pope2022-11-105-32/+31
| | | | | | | | | | | | | | | - Updated references to RFC 1123 to RFC 5322 - Only partial as RFC 5322 sort of sub-references RFC 1123. - Updated references to RFC 2388 to RFC 7578 - Except RFC 2388 Section 5.3 which has no equivalent. - Updated references to RFC 2396 to RFC 3986 - Updated references to RFC 2616 to RFC 9110 - Updated references to RFC 3066 to RFC 5646 - Updated references to RFC 7230 to RFC 9112 - Updated references to RFC 7231 to RFC 9110 - Updated references to RFC 7232 to RFC 9110 - Updated references to RFC 7234 to RFC 9111 - Tidied up style of text when referring to RFC documents
* Used more augmented assignment statements.Nick Pope2022-10-315-7/+7
| | | | | | Identified using the following command: $ git grep -I '\(\<[_a-zA-Z0-9]\+\>\) *= *\1 *[-+/*^%&|<>@]'
* Fixed #34069 -- Made LocaleMiddleware respect language from requests when ↵Sergio2022-10-132-6/+2
| | | | i18n patterns are used.
* Refs #34000 -- Optimized handling None values in numberformat.format().Jimmy Angelakos2022-09-121-1/+1
|
* Fixed #34000 -- Fixed numberformat.format() crash on empty strings.Jimmy Angelakos2022-09-121-0/+2
|
* Refs #30213 -- Removed post-startup check for Watchman availability.Carlton Gibson2022-08-111-10/+1
| | | | | This is checked at startup in get_reloader(). The runtime check ties the implementation to Watchman excessively.
* Refs #32948, Refs #32946 -- Used Q.create() internally for dynamic Q() objects.Nick Pope2022-07-271-1/+1
| | | | | | | | | Node.create() which has a compatible signature with Node.__init__() takes in a single `children` argument rather than relying in unpacking *args in Q.__init__() which calls Node.__init__(). In addition, we were often needing to unpack iterables into *args and can instead pass a list direct to Node.create().
* Refs #32948 -- Added Node.__copy__().Nick Pope2022-07-271-0/+7
| | | | | | | | | | | This allows the copy.copy() usage in the Q._combine() method to finish sooner, instead of having to fallback to using the __reduce_ex__(4) method. Thia also avoids having to fall into copy.copy() at in Q._combine(), when combining a Q() with another Q(). Co-authored-by: Keryn Knight <keryn@kerynknight.com>
* Refs #32948 -- Simplified WhereNode and Node.__deepcopy__()/add().Nick Pope2022-07-271-3/+2
| | | | | We can use copy() in Node.add() instead of create() as we don't need the children to be cloned via [:] subscript in __init__().
* Refs #32948 -- Renamed Node._new_instance() to Node.create().Nick Pope2022-07-271-10/+6
| | | | | | | | | | | | | | | | | | | Node._new_instance() was added in 6dd2b5468fa275d53aa60fdcaff8c28bdc5e9c25 to work around Q.__init__() having an incompatible signature with Node.__init__(). It was intended as a hook that could be overridden if subclasses needed to change the behaviour of instantiation of their specialised form of Node. In practice this doesn't ever seem to have been used for this purpose and there are very few calls to Node._new_instance() with other code, e.g. Node.__deepcopy__() calling Node and overriding __class__ as required. Rename this to Node.create() to make it a more "official" piece of private API that we can use to simplify a lot of other areas internally. The docstring and nearby comment have been reworded to read more clearly.
* Refs #27236 -- Reverted "Refs #27236 -- Refactored out ↵Mariusz Felisiak2022-07-261-39/+0
| | | | | | DeprecationForHistoricalMigrationMixin." This reverts commit 57793b47657ace966ce8ce96d801ac0d85e5efc6.
* Refs #27236 -- Refactored out DeprecationForHistoricalMigrationMixin.David Wobrock2022-07-071-0/+39
|
* Updated vendored _urlsplit() to strip newline and tabs.Michael Manfre2022-07-011-2/+17
| | | | | | Refs Python CVE-2022-0391. Django is not affected, but others who incorrectly use internal function url_has_allowed_host_and_scheme() with unsanitized input could be at risk.
* Fixed #33779 -- Allowed customizing encoder class in ↵Hrushikesh Vaidya2022-06-281-2/+4
| | | | django.utils.html.json_script().
* Refs #33697 -- Used django.utils.http.parse_header_parameters() for parsing ↵Mehrdad2022-06-281-1/+12
| | | | | | | boundary streams. This also removes unused parse_header() and _parse_header_params() helpers in django.http.multipartparser.