Closed ikirudennis closed 8 years ago
Hi @ikirudennis,
I am not the maintainer of this package, but I have tried to use your more up-to-date release. I am writing a comment to you here because you don't have an issue tracker on your fork of this code.
Your release breaks if you use any Python release < 2.7 w.r.t. table rendering. Here is a simple test case:
Python 2.6:
Python 2.6.6 (r266:84292, Aug 28 2012, 10:55:56)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import textile
>>> s="""
... _This_ is a *test*
... """
>>> html = textile.textile(s)
>>> print html
<p><em>This</em> is a <strong>test</strong></p>
>>> t="""
... |^.
... |_. Foo|_. Bar|_. Baz|
... |-.
... |this|is|test|
... """
>>> html = textile.textile(t)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/path/to/python2.6/site-packages/textile/functions.py", line 1580, in textile
html_type=html_type)
File "/path/to/python2.6/site-packages/textile/functions.py", line 258, in textile
text = self.block(text, int(head_offset))
File "/path/to/python2.6/site-packages/textile/functions.py", line 754, in block
cite, line)
File "/path/to/python2.6/site-packages/textile/functions.py", line 872, in fBlock
content = self.graf(content)
File "/path/to/python2.6/site-packages/textile/functions.py", line 1058, in graf
text = self.table(text)
File "/path/to/python2.6/site-packages/textile/functions.py", line 447, in table
return pattern.sub(self.fTable, text)
File "/path/to/python2.6/site-packages/textile/functions.py", line 457, in fTable
for row in [x for x in re.split(r'\|\s*?$', match.group(3), flags=re.M) if x]:
TypeError: split() got an unexpected keyword argument 'flags'
It works under 2.7:
Python 2.7.1 (r271:86832, Aug 5 2011, 03:30:24)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import textile
>>> s="""
... _This_ is a *test*
... """
>>> html = textile.textile(s)
>>> print html
<p><em>This</em> is a <strong>test</strong></p>
>>> t="""
... |^.
... |_. Foo|_. Bar|_. Baz|
... |-.
... |this|is|test|
... """
>>> html = textile.textile(t)
>>> print html
<table>
<thead>
<tr>
<th>Foo</th>
<th>Bar</th>
<th>Baz</th>
</tr>
</thead>
<tbody>
<tr>
<td>this</td>
<td>is</td>
<td>test</td>
</tr>
</tbody>
</table>
>>>
I understand that this is due to how Python has implemented re.split() under 2.7 - "Changed in version 2.7: Added the optional flags argument."
You might like to update your fork to handle Python < 2.7. At the very least you should explicitly tell users in your forks README that your release breaks Textile table rendering (and maybe elsewhere where you use the re.split() method).
I had to figure this out after applying your fork and then seeing all my site's table break across the board.
Regards,
Hi, @robnewman. Firstly, thanks for using my fork. I'm sorry if I caused you a bit of a headache trying to troubleshoot that problem. I think we've all been in that situation and it's never fun.
I've enabled the issue tracker, so if you'd like you can post this as an issue. I'm not sure that it will be particularly easy to provide this backward compatibility, but I'll take a look and I'm certainly open to suggestions if you have any.
For now, I suppose a note in the README about supported Python versions is the quickest solution. I had planned on actively working on this again to finish off the remaining features in the TODO, so be on the lookout for those in the coming weeks.
Again, thanks for using my fork and bringing this to my attention. Dennis.
Hi @ikirudennis,
Thanks for the reply - will create an issue on your fork. I think the README would be enough for now - at least that would have given me pause for thought before patching my virtualenv with your fork.
Regards,
I guess this can be closed, as it's already merged in textile/python-textile?
Hi. I started off wanting to solve a few of my own edge-case problems, and wound up fixing all the problems that were at least causing the tests to fail. There's still one problem test case that appears to only fail because nose doesn't handle unicode properly.