aboutsummaryrefslogtreecommitdiffstats
path: root/markdown/__init__.py
diff options
context:
space:
mode:
authorWaylan Limberg <waylan@gmail.com>2014-09-25 22:26:07 -0400
committerWaylan Limberg <waylan@gmail.com>2014-09-25 22:26:07 -0400
commit8f878c37dc3613b7279a0787bdcaf2d66b348d74 (patch)
treee49cbfe51f1d180ae22af9e6c33e92ca11fbd609 /markdown/__init__.py
parent39c8c1c64fe04bbde625b314386cb109b11527da (diff)
downloadmarkdown-8f878c37dc3613b7279a0787bdcaf2d66b348d74.tar.gz
markdown-8f878c37dc3613b7279a0787bdcaf2d66b348d74.tar.bz2
markdown-8f878c37dc3613b7279a0787bdcaf2d66b348d74.zip
Added a temp workwround for deprecated short ext names.
As we chnaged the order in import trys for short names extensions (no dot syntax), an extra test was added to the import code for the occassion when a naming conflict exists. For example, if PyTables is installed (module name is tables) and the user tries to use the short name 'tables' instead of 'markdown.extensions.tables'. Fixes #341. Of course, this code will get ripped out when the old behavior is fully deprecated.
Diffstat (limited to 'markdown/__init__.py')
-rw-r--r--markdown/__init__.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/markdown/__init__.py b/markdown/__init__.py
index cbcee58..fdfe8b8 100644
--- a/markdown/__init__.py
+++ b/markdown/__init__.py
@@ -221,6 +221,10 @@ class Markdown(object):
# Assume string uses dot syntax (`path.to.some.module`)
module = importlib.import_module(ext_name)
logger.debug('Successfuly imported extension module "%s".' % ext_name)
+ # For backward compat (until deprecation) check that this is an extension
+ if '.' not in ext_name and not (hasattr(module, 'extendMarkdown') or (class_name and hasattr(module, class_name))):
+ # We have a name conflict (eg: extensions=['tables'] and PyTables is installed)
+ raise ImportError
except ImportError:
# Preppend `markdown.extensions.` to name
module_name = '.'.join(['markdown.extensions', ext_name])