Skip to content

Commit

Permalink
[5.1.x] Refs #35326 -- Adjusted deprecation warning stacklevel in Fil…
Browse files Browse the repository at this point in the history
…eSystemStorage.OS_OPEN_FLAGS.

Backport of 47f18a7 from main.
  • Loading branch information
charettes authored and nessita committed Aug 28, 2024
1 parent c87007a commit 8f5d2c3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions django/core/files/storage/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def __init__(
"Overriding OS_OPEN_FLAGS is deprecated. Use "
"the allow_overwrite parameter instead.",
RemovedInDjango60Warning,
stacklevel=2,
)

@cached_property
Expand Down
4 changes: 4 additions & 0 deletions docs/releases/5.1.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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`).
3 changes: 2 additions & 1 deletion tests/file_storage/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,10 +635,11 @@ def setUp(self):
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.
Expand Down

0 comments on commit 8f5d2c3

Please sign in to comment.