Skip to content

Commit

Permalink
Fix instead import module in DeprecationWarning
Browse files Browse the repository at this point in the history
  • Loading branch information
junnplus committed Nov 16, 2019
1 parent 1aba740 commit 6ee2536
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/werkzeug/__init__.py
Expand Up @@ -53,13 +53,15 @@ 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__,
package=package,
item=item,
removed_in=self._removed_in,
origin=origin,
Expand Down

0 comments on commit 6ee2536

Please sign in to comment.