Skip to content
This repository has been archived by the owner on Jul 10, 2021. It is now read-only.

Commit

Permalink
Cleanup and docs for our shim
Browse files Browse the repository at this point in the history
  • Loading branch information
kfdm committed Mar 11, 2013
1 parent 145b9d3 commit c117ba8
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions gntp/shim.py
@@ -1,3 +1,10 @@
"""
Python2.5 and Python3.3 compatibility shim
Heavily inspirted by the "six" library.
https://pypi.python.org/pypi/six
"""

import sys

PY3 = sys.version_info[0] == 3
Expand All @@ -13,9 +20,7 @@ def u(s):
return s.decode('utf8', 'replace')
return s

import io
StringIO = io.StringIO
BytesIO = io.BytesIO
from io import StringIO
from configparser import RawConfigParser
else:
def b(s):
Expand All @@ -30,7 +35,8 @@ def u(s):
s = str(s)
return unicode(s, "utf8", "replace")

int2byte = chr
import StringIO
StringIO = BytesIO = StringIO.StringIO
from StringIO import StringIO
from ConfigParser import RawConfigParser

b.__doc__ = "Ensure we have a byte string"
u.__doc__ = "Ensure we have a unicode string"

0 comments on commit c117ba8

Please sign in to comment.