Django-rest-framework: AttributeError: 'module' object has no attribute 'version' with Markdown 3.0 release

Created on 22 Sep 2018  路  5Comments  路  Source: encode/django-rest-framework

Checklist

  • [x] I have verified that that issue exists against the master branch of Django REST framework.
  • [x] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • [x] This is not a usage question. (Those should be directed to the discussion group instead.)
  • [x] This cannot be dealt with as a third party library. (We prefer new functionality to be in the form of third party libraries where possible.)
  • [x] I have reduced the issue to the simplest possible case.
  • [x] I have included a failing test as a pull request. (If you are unable to do so we can still accept the issue.)

Steps to reproduce

The newest release Markdown 3.0 break rest_framework
https://pypi.org/project/Markdown/#history

pip install Markdown==3.0

In [1]: from rest_framework import compat
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-482462874c04> in <module>()
----> 1 from rest_framework import compat

./venv/lib/python2.7/site-packages/rest_framework/compat.py in <module>()
    159     import markdown
    160 
--> 161     if markdown.version <= '2.2':
    162         HEADERID_EXT_PATH = 'headerid'
    163         LEVEL_PARAM = 'level'

AttributeError: 'module' object has no attribute 'version'

Most helpful comment

FYI, markdown 3.0.1 with compatibility fix (version) has been released, so, I guess, this ticket can be closed.

https://github.com/Python-Markdown/markdown/commit/6323ba6c98cadc19c0a7eebe9b09279b738dc109

All 5 comments

This is also happening with me. An appropriate attribute is __version__:

Python 3.6.6 (default, Sep 12 2018, 18:26:19) 
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import markdown
>>> markdown.version
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'markdown' has no attribute 'version'
>>> markdown.__version__
'3.0'

Eh - this is no fix - "use an old version". Why just don't you check for markdown.__version__, as suggested? Does Markdown 3 break DRF, or does simply DRF use an old attr. BTW,[Markdown resurrected the variable], so this bug could be closed just by waiting on markdown>=3.0.1 or so.
Why don't patch DRF to use __version__?

Why don't patch DRF to use version?

We could, yes. Tho that's not supported until the most recent release - 3.0, so we'd need to do a more careful check ("Use this attribute if it exists, otherwise use that one")

FYI, markdown 3.0.1 with compatibility fix (version) has been released, so, I guess, this ticket can be closed.

https://github.com/Python-Markdown/markdown/commit/6323ba6c98cadc19c0a7eebe9b09279b738dc109

Thanks for the update @zyv!

Was this page helpful?
0 / 5 - 0 ratings