Skip to content

Commit

Permalink
Part of previous commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Jun 1, 2015
1 parent 28a1938 commit c58c72e
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/zope/session/_compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
##############################################################################
#
# Copyright (c) 2015 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
import sys

if sys.version_info[0] < 3:

PY2 = True
PY3 = False

def _u(s, encoding='unicode_escape'):
return unicode(s, encoding)

else:

PY2 = False
PY3 = True

def _u(s, encoding=None):
if encoding is None:
return s
return str(s, encoding)

0 comments on commit c58c72e

Please sign in to comment.