summaryrefslogtreecommitdiff
path: root/magic
diff options
context:
space:
mode:
authorAdam Hupp <adam@hupp.org>2021-01-15 15:24:35 -0800
committerAdam Hupp <adam@hupp.org>2021-01-15 15:24:35 -0800
commit0a456a752785203b655aff7237a335df37545815 (patch)
tree0d4f2ed9e7a49406c1ca16d933ed8f5c52a8732b /magic
parent086b2abab4b040d9956ee88799d27f0de313a231 (diff)
downloadpython-magic-0a456a752785203b655aff7237a335df37545815.tar.gz
add more doc pointers for compat mode, and enable PendingDeprecationWarning
Diffstat (limited to 'magic')
-rw-r--r--magic/__init__.py24
1 files changed, 11 insertions, 13 deletions
diff --git a/magic/__init__.py b/magic/__init__.py
index 554f3f5..f2fd34d 100644
--- a/magic/__init__.py
+++ b/magic/__init__.py
@@ -450,25 +450,23 @@ def _add_compat(to_module):
import warnings, re
from magic import compat
- def deprecation_wrapper(compat, fn, alternate):
+ def deprecation_wrapper(fn):
def _(*args, **kwargs):
warnings.warn(
- "Using compatability mode with libmagic's python binding",
- DeprecationWarning)
+ "Using compatability mode with libmagic's python binding. "
+ "See https://github.com/ahupp/python-magic/blob/master/COMPAT.md for details.",
+ PendingDeprecationWarning)
- return compat[fn](*args, **kwargs)
+ return fn(*args, **kwargs)
return _
- fn = [('detect_from_filename', 'magic.from_file'),
- ('detect_from_content', 'magic.from_buffer'),
- ('detect_from_fobj', 'magic.Magic.from_open_file'),
- ('open', 'magic.Magic')]
- for (fname, alternate) in fn:
- # for now, disable the deprecation warning until theres clarity on
- # what the merged module should look like
- to_module[fname] = compat.__dict__.get(fname)
- # to_module[fname] = deprecation_wrapper(compat.__dict__, fname, alternate)
+ fn = ['detect_from_filename',
+ 'detect_from_content',
+ 'detect_from_fobj',
+ 'open']
+ for fname in fn:
+ to_module[fname] = deprecation_wrapper(compat.__dict__[fname])
# copy constants over, ensuring there's no conflicts
is_const_re = re.compile("^[A-Z_]+$")