textile / python-textile

A Python port of Textile, A humane web text generator
Other
68 stars 23 forks source link

Incompatible with Python 2.6 due to use of flags argument to re.sub #48

Closed rjollos closed 7 years ago

rjollos commented 7 years ago

The commit cf7faf77 uses the flags argument to re.sub, which is only available since Python 2.7.

This result in a test failure with Python 2.6 for the Trac project:

Traceback (most recent call last):
  File "C:\projects\trac\trac\mimeview\tests\txtl.py", line 84, in test_html
    """)
  File "C:\projects\trac\trac\mimeview\tests\txtl.py", line 35, in _render
    result = self.renderer.render(self.context, 'textile', text)
  File "C:\projects\trac\trac\mimeview\txtl.py", line 73, in render
    output = render_textile(content)
  File "C:\projects\trac\trac\mimeview\txtl.py", line 46, in render_textile
    return textile.textile(text)
  File "C:\Python26\lib\site-packages\textile\core.py", line 1417, in textile
    return Textile(html_type=html_type).parse(text)
  File "C:\Python26\lib\site-packages\textile\core.py", line 237, in parse
    text = normalize_newlines(text)
  File "C:\Python26\lib\site-packages\textile\utils.py", line 114, in normalize_newlines
    out = re.sub(r'^[ \t]*\n', '\n', out, flags=re.M)
TypeError: sub() got an unexpected keyword argument 'flags'
rjollos commented 7 years ago

I noticed the deprecation warning about Textile with Python 2.6, but don't see that support has actually been dropped:

C:\Python26-x64\lib\site-packages\textile\__init__.py:19: DeprecationWarning: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of textile will drop support for Python 2.6
  DeprecationWarning

If you decide to drop support for Python 2.6 we'll just pin older Trac versions on Textile 2.3.12. Newer versions of Trac supports Python 2.7+, however we still have maintenance lines that support Python 2.5 and 2.6.

ikirudennis commented 7 years ago

This is a little bit surprising given that we have travis set to test against py26. There might be a way around this, though. I'll see what I can do.

ikirudennis commented 7 years ago

Hi, @rjollos. Would you be able to try testing against the develop branch? pip install -e git+https://github.com/textile/python-textile.git@develop#egg=textile

rjollos commented 7 years ago

Sure, I'll run the tests and report back.

rjollos commented 7 years ago

Tests are passing on TravisCI and AppVeyor. Thanks!