Commit Graph

1743 Commits

Author SHA1 Message Date
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
Florian Apolloner e1d673c373 Fixed unescape_string_literal() crash on empty strings. 2021-12-14 20:19:44 +01:00
Maxim Piskunov d3f4c2b95d Fixed #33078 -- Added support for language regions in i18n_patterns(). 2021-12-03 12:57:06 +01:00
Mariusz Felisiak 5def7f3f74 Updated various links to HTTPS and new locations.
Co-Authored-By: Nick Pope <nick@nickpope.me.uk>
2021-12-02 11:27:29 +01:00
Baptiste Mispelon e6e664a711 Fixed #33302 -- Made element_id optional argument for json_script template filter.
Added versionchanged note in documentation
2021-11-22 11:52:19 +01:00
tim-mccurrach 1f9874d4ca
Refs #33245 -- Minor edits to django.utils.html.urlize() changes.
Follow up to ad81b606a2.
2021-11-03 08:14:50 +01:00
Timothy McCurrach ad81b606a2 Fixed #33245 -- Made django.utils.html.urlize() thread-safe.
Regression in e567670b1a.
2021-11-01 06:27:58 +01:00
Vinay Karanam 8806e8809e Fixed #33043 -- Made method_decorator() preserve wrapper assignments.
Regression in f434f5b84f.
2021-10-20 16:48:00 +02:00
Claude Paroz e567670b1a Fixed #33195 -- Refactored urlize() based on a class.
This allows easier customization/
2021-10-15 09:20:01 +02:00
Claude Paroz 514c16e85f
Removed unused DOTS list.
Unused since 4ff389dcdc.
2021-10-14 19:56:37 +02:00
Ade Lee d10c7bfe56 Fixed #28401 -- Allowed hashlib.md5() calls to work with FIPS kernels.
md5 is not an approved algorithm in FIPS mode, and trying to instantiate
a hashlib.md5() will fail when the system is running in FIPS mode.

md5 is allowed when in a non-security context. There is a plan to add a
keyword parameter (usedforsecurity) to hashlib.md5() to annotate whether
or not the instance is being used in a security context.

In the case where it is not, the instantiation of md5 will be allowed.
See https://bugs.python.org/issue9216 for more details.

Some downstream python versions already support this parameter. To
support these versions, a new encapsulation of md5() has been added.
This encapsulation will pass through the usedforsecurity parameter in
the case where the parameter is supported, and strip it if it is not.

Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2021-10-12 08:58:27 +02:00
Nick Pope a3185a6701
Refs #33107 -- Optimized cached_import() helper. 2021-10-04 07:47:49 +02:00
Adam Johnson 37d9ea5d5c Optimized @async_unsafe.
Switched the order of the checks to reduce the overhead. Async unsafe methods
are *normally* called syncrhonously, so we can avoid the overhead of checking
the environment variable in the regular path.
2021-09-30 12:16:00 +02:00
Chenyang Yan 36d54b7a14 Fixed #33027 -- Made autoreloader pass -X options. 2021-09-29 11:37:50 +02:00
Mariusz Felisiak 5bac1719a2
Refs #32355 -- Used @functools.lru_cache as a straight decorator. 2021-09-27 09:10:58 +02:00
Adam Johnson 840ad06300 Refs #32355 -- Modernized subprocess.run() calls. 2021-09-27 08:20:24 +02:00
Illia Volochii bc4c7e5d68 Optimized handling case-insensitive mappings.
Elements yielded by _destruct_iterable_mapping_values are always
unpacked. Since unpacking can be done with any iterable, there is no
need to convert elements to tuples. Also, such elements can be used
directly in for loops, creating a dictionary of them is excessive.

Co-authored-by: Nick Pope <nick@nickpope.me.uk>
2021-09-22 09:26:21 +02:00
Mariusz Felisiak 8b6d0333cf Advanced deprecation warnings for Django 4.1. 2021-09-20 21:23:01 +02:00
Carlton Gibson 306607d5b9 Fixed #32365 -- Made zoneinfo the default timezone implementation.
Thanks to Adam Johnson, Aymeric Augustin, David Smith, Mariusz Felisiak, Nick
Pope, and Paul Ganssle for reviews.
2021-09-16 12:11:05 +02:00
Mariusz Felisiak 6426c3077c
Fixed #33107 -- Fixed import_string() crash on not fully initialized modules.
Regression in ecf87ad513.

Thanks Collin Anderson for the report.
2021-09-16 07:12:58 +02:00
Claude Paroz 676bd084f2 Fixed #32873 -- Deprecated settings.USE_L10N.
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2021-09-14 12:05:43 +02:00
yujin ecf87ad513 Fixed #33099 -- Improved performance of import_string().
This improves performance of import_string() by avoiding multiple
imports for the same path.

Thanks Andrew Godwin and Keryn Knight for the implementation idea.
2021-09-10 12:37:00 +02:00
Carlton Gibson cbba49971b Fixed #32992 -- Restored offset extraction for fixed offset timezones.
Regression in 10d1261984.
2021-08-30 10:12:46 +02:00
David Smith 8208381ba6 Refs #32956 -- Corrected spelling of daylight saving time.
AP Stylebook: Saving not savings, no hyphen, and lowercase.
2021-08-06 13:00:24 +02:00
Chris Jerdonek 4fe3774c72 Refs #32986 -- Moved TRANSLATOR_COMMENT_MARK to django.utils.translation.template. 2021-08-05 06:11:40 +02:00
David Smith fbb1984046
Refs #32956 -- Updated words ending in -wards.
AP styleguide: Virtually none of the words ending with -wards end with
an s.
2021-07-30 20:34:50 +02:00
David Smith 1024b5e74a Fixed 32956 -- Lowercased spelling of "web" and "web framework" where appropriate. 2021-07-29 06:24:12 +02:00
Keryn Knight ff661dbd50 Refs #32940 -- Removed unnecessary branch in Node.add().
The "data in self.children" branch was causing data.__eq__ to be
called for each entries in "self.children" which resulted in a huge
slowdown during queryset construction.

It's purpose was to prevent queries of the form
    Model.objects.filter(foo='bar').filter(foo='bar')
from resulting in
    WHERE foo='bar' AND foo='bar'
but it's not covered by the suite and has arguable performance benefits
since it's not very common and SQL engines are usually very good at
folding/optimizing these.

See also #32632 for prior discussion around comparing data to the
Node's children.

Co-authored-by: Nick Pope <nick@nickpope.me.uk>
2021-07-20 07:19:28 +02:00
Keryn Knight fb35e0a2fe Refs #32940 -- Removed Node.add()'s unused squash parameter.
Unused since its introduction in d3f00bd570.

Co-authored-by: Nick Pope <nick@nickpope.me.uk>
2021-07-20 07:19:28 +02:00
Keryn Knight 59942a66ce Fixed #32941 -- Removed get_format_modules()'s unused reverse argument.
Unused since 0d8b523422.
2021-07-19 11:42:20 +02:00
Nick Pope e21daa4e4c
Removed unnecessary tuple construction in Node.__eq__(). 2021-07-19 06:38:35 +02:00
Nick Pope 1f4908b01a Simplified django.utils.dateformat methods.
This removes unnecessary format('O') call, remove unnecessary method
calls for simple cases in TimeFormat, and simplifies time zone handling
in TimeFormat.
2021-07-13 13:27:01 +02:00
abhiabhi94 cf6774a53b Fixed #32904 -- Made parse_time() more strict.
Thanks Keryn Knight for the report.
2021-07-07 12:08:43 +02:00
Shipeng Feng 68cc04887b
Fixed #32866 -- Fixed trimming trailing punctuation from escaped string in urlize(). 2021-07-07 11:19:33 +02:00
Keryn Knight f35ab74752 Fixed #32892 -- Optimized django.utils.dateparse functions by using fromisoformat(). 2021-07-06 08:57:17 +02:00
Daniele Procida e3d55eeb14 Refs #32880 -- Moved logging reference to new document.
Completed a first step in moving reference and how-to material out of
the topic document.
2021-06-30 07:21:52 +02:00
Ben Wilber fff4870bfa Fixed #32727 -- Allowed spaces before time zone offset in parse_datetime(). 2021-06-24 10:07:55 +02:00
Illia Volochii 5a468b4c08 Fixed #32859 -- Simplified compress_string() by using gzip.compress(). 2021-06-21 13:19:11 +02:00
Mateo Radman d6f3b58589 Fixed #32810 -- Optimized django.utils.formats.number_format() a bit.
Pre-calculate use_l10n for get_format() calls.
2021-06-05 13:48:26 +02:00
David Sanders 5685b7cd73
Fixed typos in comments and docs. 2021-05-29 12:51:14 +02:00