diff options
| author | Charles Merriam <charles.merriam@gmail.com> | 2020-04-19 15:29:28 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-19 18:29:28 -0400 |
| commit | 7daa6740e143aea914bf81f5f843eb8c5562f2ba (patch) | |
| tree | edd6d36d6b61b742fe4c0aed12d7b0cd3756769d /markdown/extensions | |
| parent | bbfdd5548d7930a281dc4f70a2ed6d80ed266bf9 (diff) | |
| download | python-markdown-7daa6740e143aea914bf81f5f843eb8c5562f2ba.tar.gz | |
Correctly report if an extension raises a `TypeError`.
Also Raise a `KeyError` when attempting to delete a nonexistent key from the extension registry.
Diffstat (limited to 'markdown/extensions')
| -rw-r--r-- | markdown/extensions/__init__.py | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/markdown/extensions/__init__.py b/markdown/extensions/__init__.py index 010e310..4bc8e5f 100644 --- a/markdown/extensions/__init__.py +++ b/markdown/extensions/__init__.py @@ -75,15 +75,18 @@ class Extension: md = args[0] try: self.extendMarkdown(md) - except TypeError: - # Must be a 2.x extension. Pass in a dumby md_globals. - self.extendMarkdown(md, {}) - warnings.warn( - "The 'md_globals' parameter of '{}.{}.extendMarkdown' is " - "deprecated.".format(self.__class__.__module__, self.__class__.__name__), - category=DeprecationWarning, - stacklevel=2 - ) + except TypeError as e: + if "missing 1 required positional argument" in str(e): + # Must be a 2.x extension. Pass in a dumby md_globals. + self.extendMarkdown(md, {}) + warnings.warn( + "The 'md_globals' parameter of '{}.{}.extendMarkdown' is " + "deprecated.".format(self.__class__.__module__, self.__class__.__name__), + category=DeprecationWarning, + stacklevel=2 + ) + else: + raise def extendMarkdown(self, md): """ |
