summaryrefslogtreecommitdiff
path: root/astroid/util.py
diff options
context:
space:
mode:
authorCeridwen <ceridwenv@gmail.com>2015-10-23 18:02:23 -0400
committerCeridwen <ceridwenv@gmail.com>2015-10-23 18:02:23 -0400
commit1784ce236fe5654675f034b9638e6cd3ade2e418 (patch)
treec4082ccb483b04b27abdd0cc6ddb25f2682a9227 /astroid/util.py
parentcebae7cfd226da981fea3f09c016b6ac8abf654a (diff)
downloadastroid-git-1784ce236fe5654675f034b9638e6cd3ade2e418.tar.gz
Transfer build_function and ast_from_function from modular_locals to zipper
Diffstat (limited to 'astroid/util.py')
-rw-r--r--astroid/util.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/astroid/util.py b/astroid/util.py
index 9cd1d9dc..05d48a65 100644
--- a/astroid/util.py
+++ b/astroid/util.py
@@ -20,6 +20,7 @@
# the same license.
import importlib
+import platform
import sys
import warnings
@@ -28,6 +29,8 @@ import six
from astroid import exceptions
+JYTHON = True if platform.python_implementation() == 'Jython' else False
+
def lazy_import(module_name):
return lazy_object_proxy.Proxy(
@@ -38,6 +41,18 @@ def reraise(exception):
block.'''
six.reraise(type(exception), exception, sys.exc_info()[2])
+def generate_warning(message, warning):
+ return lambda strings: warnings.warn(message % strings, warning,
+ stacklevel=3)
+
+rename_warning = generate_warning("%r is deprecated and slated for removal in "
+ "astroid 2.0, use %r instead",
+ PendingDeprecationWarning)
+
+attr_to_method_warning = generate_warning("%s is deprecated and slated for "
+ " removal in astroid 1.6, use the "
+ "method '%s' instead.",
+ PendingDeprecationWarning)
@object.__new__
class YES(object):
@@ -60,10 +75,7 @@ def _instancecheck(cls, other):
wrapped = cls.__wrapped__
other_cls = other.__class__
is_instance_of = wrapped is other_cls or issubclass(other_cls, wrapped)
- warnings.warn("%r is deprecated and slated for removal in astroid "
- "2.0, use %r instead" % (cls.__class__.__name__,
- wrapped.__name__),
- PendingDeprecationWarning, stacklevel=2)
+ rename_warning((cls.__class__.__name__, wrapped.__name__))
return is_instance_of