diff options
| author | Simon Charette <charette.s@gmail.com> | 2024-08-09 12:45:44 -0400 |
|---|---|---|
| committer | Natalia <124304+nessita@users.noreply.github.com> | 2024-08-28 11:46:23 -0300 |
| commit | 8f5d2c374a150fca063443292cdf2618026bda42 (patch) | |
| tree | be16104c080bae77b7eb1b98739cc598b37c4957 | |
| parent | c87007ab60f69df7f991e5e6fe113dbaaba94787 (diff) | |
[5.1.x] Refs #35326 -- Adjusted deprecation warning stacklevel in FileSystemStorage.OS_OPEN_FLAGS.
Backport of 47f18a722624527cc72eef44cfc9d1e07ea4b4e0 from main.
| -rw-r--r-- | django/core/files/storage/filesystem.py | 1 | ||||
| -rw-r--r-- | docs/releases/5.1.1.txt | 4 | ||||
| -rw-r--r-- | tests/file_storage/tests.py | 3 |
3 files changed, 7 insertions, 1 deletions
diff --git a/django/core/files/storage/filesystem.py b/django/core/files/storage/filesystem.py index 310a0ed0de..bf2b9caad4 100644 --- a/django/core/files/storage/filesystem.py +++ b/django/core/files/storage/filesystem.py @@ -48,6 +48,7 @@ class FileSystemStorage(Storage, StorageSettingsMixin): "Overriding OS_OPEN_FLAGS is deprecated. Use " "the allow_overwrite parameter instead.", RemovedInDjango60Warning, + stacklevel=2, ) @cached_property diff --git a/docs/releases/5.1.1.txt b/docs/releases/5.1.1.txt index 84a61efec5..82a7aed1c8 100644 --- a/docs/releases/5.1.1.txt +++ b/docs/releases/5.1.1.txt @@ -23,3 +23,7 @@ Bugfixes * Adjusted the deprecation warning ``stacklevel`` in :meth:`.Model.save` and :meth:`.Model.asave` to correctly point to the offending call site (:ticket:`35060`). + +* Adjusted the deprecation warning ``stacklevel`` when using ``OS_OPEN_FLAGS`` + in :class:`~django.core.files.storage.FileSystemStorage` to correctly point + to the offending call site (:ticket:`35326`). diff --git a/tests/file_storage/tests.py b/tests/file_storage/tests.py index c7ca873521..9b643128d1 100644 --- a/tests/file_storage/tests.py +++ b/tests/file_storage/tests.py @@ -635,10 +635,11 @@ class OverwritingStorageOSOpenFlagsWarningTests(SimpleTestCase): def test_os_open_flags_deprecation_warning(self): msg = "Overriding OS_OPEN_FLAGS is deprecated. Use the allow_overwrite " msg += "parameter instead." - with self.assertWarnsMessage(RemovedInDjango60Warning, msg): + with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx: self.storage = self.storage_class( location=self.temp_dir, base_url="/test_media_url/" ) + self.assertEqual(ctx.filename, __file__) # RemovedInDjango60Warning: Remove this test class. |
