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 d54f108
Showing 1 changed file with 4 additions and 2 deletions.
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 d54f108

Please sign in to comment.