Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix rename DeprecationWarning message for subpackages #1664

Merged
merged 1 commit into from Jan 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGES.rst
@@ -1,5 +1,12 @@
.. currentmodule:: werkzeug

Version 0.16.1
--------------

- Fix import location in deprecation messages for subpackages.
:issue:`1663`


Version 0.16.0
--------------

Expand Down
6 changes: 4 additions & 2 deletions src/werkzeug/__init__.py
Expand Up @@ -53,15 +53,17 @@ def __getattr__(self, item):

# Import the module, get the attribute, and show a warning about where
# to correctly import it from.
mod = import_module(origin, self.__name__.rsplit(".")[0])
package = self.__name__.rsplit(".")[0]
mod = import_module(origin, package)
value = getattr(mod, item)
warn(
"The import '{name}.{item}' is deprecated and will be removed in"
" {removed_in}. Use 'from {name}{origin} import {item}'"
" {removed_in}. Use 'from {package}{origin} import {item}'"
" instead.".format(
name=self.__name__,
item=item,
removed_in=self._removed_in,
package=package,
origin=origin,
),
DeprecationWarning,
Expand Down