Skip to content
This repository

Need to decode unicode posts in python 2 #10

Closed
wants to merge 1 commit into from

2 participants

Jeff Dairiki Doug Latornell
Jeff 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.)

Jeff 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
Jeff Dairiki dairiki referenced this pull request in EnigmaCurry/blogofile June 19, 2012
Closed

Unicode problems on mac os #122

Doug Latornell
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.

Doug Latornell douglatornell closed this June 19, 2012
Jeff Dairiki

No problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jun 19, 2012
Jeff 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
This page is out of date. Refresh to see the latest.
3  blogofile_blog/site_src/_controllers/blog/post.py
@@ -27,6 +27,7 @@
27 27
 import pytz
28 28
 import yaml
29 29
 import logging
  30
+from six import text_type
30 31
 
31 32
 from blogofile import util
32 33
 import blogofile_bf as bf
@@ -401,6 +402,8 @@ def parse_posts(directory):
401 402
         try:
402 403
             with open(post_path, "r") as src_file:
403 404
                 src = src_file.read()
  405
+            if not isinstance(src, text_type):
  406
+                src = src.decode('utf-8')
404 407
         except:
405 408
             logger.exception("Error reading post: {0}".format(post_path))
406 409
             raise
1  setup.py
@@ -24,6 +24,7 @@
24 24
 
25 25
 dependencies = ['argparse'] if PY26 else []
26 26
 
  27
+dependencies += ['six']
27 28
 
28 29
 def find_package_data(module, path):
29 30
     """Find all data files to include in the package.
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.