summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Hupp <adam@hupp.org>2018-01-14 19:23:55 -0800
committerAdam Hupp <adam@hupp.org>2018-01-14 19:23:55 -0800
commit798aa067dec6298edf4855eb899324e1aab20ca1 (patch)
tree100626e6b392903bf38211bb99695c6bfc154149
parenta0b9f316fda16b21923bb57e1de9a98789befbba (diff)
downloadpython-magic-798aa067dec6298edf4855eb899324e1aab20ca1.tar.gz
various cleanups proposed by debian folks
-rw-r--r--magic/__init__.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/magic/__init__.py b/magic/__init__.py
index 6ccc8d9..66e33de 100644
--- a/magic/__init__.py
+++ b/magic/__init__.py
@@ -25,6 +25,8 @@ import logging
from ctypes import c_char_p, c_int, c_size_t, c_void_p, byref, POINTER
+# avoid shadowing the real open with the version from compat.py
+_real_open = open
class MagicException(Exception):
def __init__(self, message):
@@ -114,8 +116,7 @@ class Magic:
def from_file(self, filename):
# raise FileNotFoundException or IOError if the file does not exist
- # use __builtins__ because the compat stuff at the bottom shadows the builtin open
- with __builtins__['open'](filename):
+ with _real_open(filename):
pass
with self.lock:
@@ -462,7 +463,10 @@ def add_compat(to_module):
('detect_from_fobj', 'magic.Magic.from_open_file'),
('open', 'magic.Magic')]
for (fname, alternate) in fn:
- to_module[fname] = deprecation_wrapper(compat.__dict__, fname, alternate)
+ # 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)
# copy constants over, ensuring there's no conflicts
is_const_re = re.compile("^[A-Z_]+$")