Skip to content

Commit

Permalink
fix rename DeprecationWarning message for subpackages
Browse files Browse the repository at this point in the history
  • Loading branch information
junnplus authored and davidism committed Jan 4, 2020
1 parent d6a607b commit e3a880b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
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

0 comments on commit e3a880b

Please sign in to comment.