[Python-modules-commits] [python-textile] 01/04: Import python-textile_2.3.3.orig.tar.gz
Dmitry Shachnev
mitya57 at moszumanska.debian.org
Thu Jul 28 15:48:31 UTC 2016
This is an automated email from the git hooks/post-receive script.
mitya57 pushed a commit to branch master
in repository python-textile.
commit f9ee586f1692057ac17a4b4777b24576aae3559d
Author: Dmitry Shachnev <mitya57 at gmail.com>
Date: Thu Jul 28 18:46:29 2016 +0300
Import python-textile_2.3.3.orig.tar.gz
---
CHANGELOG.textile | 4 ++++
tests/test_github_issues.py | 6 ++++++
textile/__init__.py | 12 ++++++++++++
textile/core.py | 5 ++++-
textile/utils.py | 10 +++++-----
textile/version.py | 2 +-
6 files changed, 32 insertions(+), 7 deletions(-)
diff --git a/CHANGELOG.textile b/CHANGELOG.textile
index 06f8e8d..9f8ffcd 100644
--- a/CHANGELOG.textile
+++ b/CHANGELOG.textile
@@ -1,5 +1,9 @@
h1. Textile Changelog
+h2. Version 2.3.3
+* Bugfix: Unicode in URL titles no longer break everything ("#30":https://github.com/textile/python-textile/issues/30)
+* Display DeprecationWarning when using textile on Python 2.6.
+
h2. Version 2.3.2
* Bugfix: properly handle @":"@ as text, not a link.
diff --git a/tests/test_github_issues.py b/tests/test_github_issues.py
index fa14237..20448c7 100644
--- a/tests/test_github_issues.py
+++ b/tests/test_github_issues.py
@@ -79,3 +79,9 @@ def parseWapProfile(self, url):
\t<p>Of course there’s a lot more error handling to do (and useful data to glean off the <a href="XML"><span class="caps">XML</span></a>), but being able to cut through all the usual parsing crap is immensely gratifying.</p>""")
assert result == expect
+
+def test_github_issue_30():
+ text ='"Tëxtíle (Tëxtíle)":http://lala.com'
+ result = textile.textile(text)
+ expect = '\t<p><a href="http://lala.com" title="Tëxtíle">Tëxtíle</a></p>'
+ assert result == expect
diff --git a/textile/__init__.py b/textile/__init__.py
index e7ea665..c019f41 100644
--- a/textile/__init__.py
+++ b/textile/__init__.py
@@ -1,8 +1,20 @@
from __future__ import unicode_literals
+import sys
+import warnings
+
from .core import textile, textile_restricted, Textile
from .version import VERSION
__all__ = ['textile', 'textile_restricted']
__version__ = VERSION
+
+
+if sys.version_info[:2] == (2, 6):
+ warnings.warn(
+ "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
+ )
diff --git a/textile/core.py b/textile/core.py
index 5cac161..7cc7439 100644
--- a/textile/core.py
+++ b/textile/core.py
@@ -874,7 +874,10 @@ class Textile(object):
url = self.shelveURL(self.encode_url(urlunsplit(uri_parts)))
attributes = parse_attributes(atts)
if title:
- attributes['title'] = title
+ # if the title contains unicode data, it is annoying to get Python
+ # 2.6 and all the latter versions working properly. But shelving
+ # the title is a quick and dirty solution.
+ attributes['title'] = self.shelve(title)
attributes['href'] = url
if self.rel:
attributes['rel'] = self.rel
diff --git a/textile/utils.py b/textile/utils.py
index d917e9e..89e35e8 100644
--- a/textile/utils.py
+++ b/textile/utils.py
@@ -50,16 +50,16 @@ def generate_tag(tag, content, attributes=None):
content are strings, the attributes argument is a dictionary. As
a convenience, if the content is ' /', a self-closing tag is generated."""
content = six.text_type(content)
- element = ElementTree.Element(tag, attrib=attributes)
enc = 'unicode'
if six.PY2:
enc = 'UTF-8'
if not tag:
return content
+ element = ElementTree.Element(tag, attrib=attributes)
# FIXME: Kind of an ugly hack. There *must* be a cleaner way. I tried
- # adding text by assigning it to a.text. That results in non-ascii text
- # being html-entity encoded. Not bad, but not entirely matching
- # php-textile either.
+ # adding text by assigning it to element_tag.text. That results in
+ # non-ascii text being html-entity encoded. Not bad, but not entirely
+ # matching php-textile either.
try:
element_tag = ElementTree.tostringlist(element, encoding=enc,
method='html')
@@ -67,7 +67,7 @@ def generate_tag(tag, content, attributes=None):
element_text = ''.join(element_tag)
except AttributeError:
# Python 2.6 doesn't have the tostringlist method, so we have to treat
- # it different.
+ # it differently.
element_tag = ElementTree.tostring(element, encoding=enc)
element_text = re.sub(r"<\?xml version='1.0' encoding='UTF-8'\?>\n",
'', element_tag)
diff --git a/textile/version.py b/textile/version.py
index a5ac616..47cb28f 100644
--- a/textile/version.py
+++ b/textile/version.py
@@ -1 +1 @@
-VERSION = '2.3.2'
+VERSION = '2.3.3'
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-textile.git
More information about the Python-modules-commits
mailing list