Commit Graph

1782 Commits

Author SHA1 Message Date
Sergio 94e7f471c4 Fixed #34069 -- Made LocaleMiddleware respect language from requests when i18n patterns are used. 2022-10-13 10:38:26 +02:00
Jimmy Angelakos 07ebef566f Refs #34000 -- Optimized handling None values in numberformat.format(). 2022-09-12 13:02:50 +02:00
Jimmy Angelakos e911e0996f Fixed #34000 -- Fixed numberformat.format() crash on empty strings. 2022-09-12 12:54:12 +02:00
Carlton Gibson e34dfad0a3 Refs #30213 -- Removed post-startup check for Watchman availability.
This is checked at startup in get_reloader(). The runtime check ties
the implementation to Watchman excessively.
2022-08-11 11:02:03 +02:00
Nick Pope 9dff316be4 Refs #32948, Refs #32946 -- Used Q.create() internally for dynamic Q() objects.
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().
2022-07-27 10:06:24 +02:00
Nick Pope 19b866c254 Refs #32948 -- Added Node.__copy__().
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>
2022-07-27 10:06:24 +02:00
Nick Pope ed9eca8457 Refs #32948 -- Simplified WhereNode and Node.__deepcopy__()/add().
We can use copy() in Node.add() instead of create() as we don't need the
children to be cloned via [:] subscript in __init__().
2022-07-27 10:06:24 +02:00
Nick Pope ddf0002bb7 Refs #32948 -- Renamed Node._new_instance() to Node.create().
Node._new_instance() was added in
6dd2b5468f 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.
2022-07-27 10:06:24 +02:00
Mariusz Felisiak 66f30dbf25 Refs #27236 -- Reverted "Refs #27236 -- Refactored out DeprecationForHistoricalMigrationMixin."
This reverts commit 57793b4765.
2022-07-26 11:41:19 +02:00
David Wobrock 57793b4765 Refs #27236 -- Refactored out DeprecationForHistoricalMigrationMixin. 2022-07-07 12:21:35 +02:00
Michael Manfre 03eec9ff6c Updated vendored _urlsplit() to strip newline and tabs.
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.
2022-07-01 08:48:38 +02:00
Hrushikesh Vaidya 72e41a0df6 Fixed #33779 -- Allowed customizing encoder class in django.utils.html.json_script(). 2022-06-28 10:54:38 +02:00
Mehrdad d4d5427571 Refs #33697 -- Used django.utils.http.parse_header_parameters() for parsing boundary streams.
This also removes unused parse_header() and _parse_header_params()
helpers in django.http.multipartparser.
2022-06-28 09:42:47 +02:00
Zainab Amir 901a169198 Fixed #23689 -- Made parsing HTTP Accept-Language header case-insensitive.
Thank you Daniel Samuels for test project.
2022-06-20 07:40:28 +02:00
Claude Paroz 292f372768 Fixed #33748 -- Fixed date template filter crash with lazy format.
Regression in 659d2421c7.
2022-05-31 06:09:39 +02:00
Aymeric Augustin aff649a3bd Normalized imports of functools.wraps.
@wraps is 10 times more common than @functools.wraps. Standardize to
the most common version.
2022-05-25 10:58:28 +02:00
Aymeric Augustin 6485894157 Renamed wrapped functions to wrapper.
All these functions are wrapping another function. They're the wrapper,
while the function they're wrapping is the wrapped.
2022-05-25 10:53:52 +02:00
Carlton Gibson cdb2f7f36c Advanced deprecation warnings for Django 4.2. 2022-05-17 14:22:06 +02:00
Nick Pope 20e65a34ae
Made closing in connection handlers more DRY. 2022-05-12 15:13:51 +02:00
Carlton Gibson 34e2148fc7 Refs #33173 -- Removed use of deprecated cgi module.
https://peps.python.org/pep-0594/#cgi
2022-05-11 14:06:31 +02:00
Andrey Otto 420d13edee
Fixed #33654 -- Added localdate to utils.timezone.__all__. 2022-04-20 09:59:48 +02:00
Carlton Gibson 59ab3fd0e9 Refs #32365 -- Deprecated django.utils.timezone.utc. 2022-03-29 14:47:44 +02:00
Carlton Gibson bb61f0186d Refs #32365 -- Removed internal uses of utils.timezone.utc alias.
Remaining test case ensures that uses of the alias are mapped
canonically by the migration writer.
2022-03-24 06:29:50 +01:00
Florian Apolloner 4f92cf87b0 Prevented initialization of unused database connections. 2022-03-17 07:40:57 +01:00
David Smith 3b3f38b3b0 Fixed #31169 -- Adapted the parallel test runner to use spawn.
Co-authored-by: Valz <ahmadahussein0@gmail.com>
Co-authored-by: Nick Pope <nick@nickpope.me.uk>
2022-03-15 16:23:55 +01:00
Mariusz Felisiak d4fd31684a
Refs #33173 -- Used locale.getlocale() instead of getdefaultlocale().
locale.getdefaultlocale() was deprecated in Python 3.11, see
https://bugs.python.org/issue46659.
2022-03-08 13:17:05 +01:00
Collin Anderson 5659015d3c
Optimized lazy wrappers a bit.
This avoids an extra __getattribute__() call for self._wrapped.
2022-03-03 06:19:11 +01:00
Keryn Knight 3de787a70b
Fixed #33532 -- Optimized CaseInsensitiveMapping instantiation for dicts.
Internal usages of this class (e.g. HttpHeaders) provide it with a dict,
so testing for that type first avoids the cost of going through the
potential __instancecheck__ + _abc_instancecheck to establish it's
a Mapping.

Co-authored-by: Nick Pope <nick@nickpope.me.uk>
2022-02-23 20:15:22 +01:00
Collin Anderson 7fd2deb3e8
Refs #32873 -- Avoided looking up settings._USE_L10N_INTERNAL twice. 2022-02-22 20:26:51 +01:00
Theo Alexiou 659d2421c7 Fixed #20296 -- Prevented mark_safe() from evaluating lazy objects. 2022-02-21 10:11:26 +01:00
Mariusz Felisiak b626c5a979
Removed unnecessary str type from @keep_lazy decorator for escape()/escapejs(). 2022-02-21 09:46:39 +01:00
saeedblanchette e559070a7a Fixed #33518 -- Added RemovedAfterNextVersionWarning. 2022-02-21 06:23:41 +01:00
David Smith fac3dd7f39
Refs #33173 -- Fixed MailTests.test_backend_arg() on Windows and Python 3.11+. 2022-02-19 20:36:01 +01:00
Matthias Kestenholz b2ed0d78f2 Refs #28358 -- Fixed infinite recursion in LazyObject.__getattribute__().
Regression in 97d7990abd.

Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
Co-authored-by: Theo Alexiou <theofilosalexiou@gmail.com>
2022-02-17 14:52:17 +01:00
Theo Alexiou 97d7990abd Fixed #28358 -- Prevented LazyObject from mimicking nonexistent attributes.
Thanks Sergey Fedoseev for the initial patch.
2022-02-16 10:51:15 +01:00
Theo Alexiou f9ec777a82 Fixed #26287 -- Added support for addition operations to SimpleLazyObject. 2022-02-10 11:24:51 +01:00
David cda81b79f2 Refs #32568 -- Optimized escape() by using SafeString instead of mark_safe(). 2022-02-10 06:39:02 +01:00
Mariusz Felisiak 7119f40c98 Refs #33476 -- Refactored code to strictly match 88 characters line length. 2022-02-07 20:37:05 +01:00
django-bot 9c19aff7c7 Refs #33476 -- Reformatted code with Black. 2022-02-07 20:37:05 +01:00
Keryn Knight 55022f75c1 Fixed #33465 -- Added empty __slots__ to SafeString and SafeData.
Despite inheriting from the str type, every SafeString instance gains
an empty __dict__ due to the normal, expected behaviour of type
subclassing in Python.

Adding __slots__ to SafeData is necessary, because otherwise inheriting
from that (as SafeString does) will give it a __dict__ and negate the
benefit added by modifying SafeString.
2022-01-29 13:50:34 +01:00
Adam Johnson 90cf963264 Changed django.utils.log.log_response() to take exception instance.
There's little point retrieving a fresh reference to the exception in
the legacy tuple format, when it's all available via the exception
instance we already have.
2022-01-12 20:23:42 +01:00
Mariusz Felisiak b111b15c12
Refs #30141 -- Removed unused branch in parse_duration().
Unused since 99fc5dc13c.
2022-01-11 11:09:08 +01:00
Mariusz Felisiak 7346c288e3
Refs #32355 -- Removed unnecessary list() calls before reversed() on dictviews.
Dict and dictviews are iterable in reversed insertion order using
reversed() in Python 3.8+.
2022-01-07 16:29:15 +01:00
Ad Timmering bdf3e156b4 Fixed #28628 -- Changed \d to [0-9] in regexes where appropriate. 2022-01-07 12:25:06 +01:00
Allen Jonathan David 205f67cd5b Refs #33216 -- Made @deconstructible do not change path for subclasses. 2022-01-04 13:15:29 +01:00
Mariusz Felisiak a21a63cc28
Refs #27753 -- Removed unused django.utils.text._replace_entity() and _entity_re.
Unused since 157ab32f34.
2021-12-30 13:19:25 +01:00
Adam Johnson 33401cba93
Optimized MiddlewareMixin coroutine check. 2021-12-21 08:41:29 +01:00
mendespedro 4fd3044ca0 Fixed #33368 -- Fixed parse_duration() crash on invalid separators for decimal fractions. 2021-12-20 06:46:34 +01:00
Adam Johnson b0d16d0129 Changed signatures of setting_changed signal receivers. 2021-12-17 13:07:04 +01:00
mgaligniana 068b2c072b Fixed #30127 -- Deprecated name argument of cached_property(). 2021-12-16 18:52:27 +01:00