Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Need to decode unicode posts in python 2 #10

Closed
wants to merge 1 commit into from

2 participants

@dairiki

Without this, unicode in posts results in errors when running under py2.
This fixes, I think, EnigmaCurry/blogofile#122.

Note: I've not tested this under py3 (though I have attempted not to break things.)

@dairiki dairiki Reintroduce the .decode() which was dropped in 8766e13
Without this, unicode in posts results in errors in py2.
E.g. EnigmaCurry/blogofile#122
0a9dd29
@dairiki dairiki referenced this pull request in EnigmaCurry/blogofile
Closed

Unicode problems on mac os #122

@douglatornell
Collaborator

Thanks for figuring this out! It does indeed resolve EnigmaCurry/blogofile#122.

The six library is already a dependency via the blogofile core, so I just used the change to post.py. So, I accepted this pull request in spirit even though I didn't actually merge it.

@dairiki

No problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 19, 2012
  1. @dairiki

    Reintroduce the .decode() which was dropped in 8766e13

    dairiki authored
    Without this, unicode in posts results in errors in py2.
    E.g. EnigmaCurry/blogofile#122
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 0 deletions.
  1. +3 −0  blogofile_blog/site_src/_controllers/blog/post.py
  2. +1 −0  setup.py
View
3  blogofile_blog/site_src/_controllers/blog/post.py
@@ -27,6 +27,7 @@
import pytz
import yaml
import logging
+from six import text_type
from blogofile import util
import blogofile_bf as bf
@@ -401,6 +402,8 @@ def parse_posts(directory):
try:
with open(post_path, "r") as src_file:
src = src_file.read()
+ if not isinstance(src, text_type):
+ src = src.decode('utf-8')
except:
logger.exception("Error reading post: {0}".format(post_path))
raise
View
1  setup.py
@@ -24,6 +24,7 @@
dependencies = ['argparse'] if PY26 else []
+dependencies += ['six']
def find_package_data(module, path):
"""Find all data files to include in the package.
Something went wrong with that request. Please try again.