From 2a7758c1233989ee793cf24402719b8c84f298f6 Mon Sep 17 00:00:00 2001 From: Donald Stufft <donald@stufft.io> Date: Sat, 9 Mar 2013 20:18:25 -0500 Subject: [PATCH] Add a six.StringFixer which does the right thing with __str__ --- nacl/six.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/nacl/six.py b/nacl/six.py index ab45e384..0838cf74 100644 --- a/nacl/six.py +++ b/nacl/six.py @@ -390,3 +390,13 @@ _add_doc(reraise, """Reraise an exception.""") def with_metaclass(meta, base=object): """Create a base class with a metaclass.""" return meta("NewBase", (base,), {}) + + +# PyNaCl additions +class StringFixer(object): + + def __str__(self): + if PY3: + return self.__unicode__() + else: + return self.__bytes__() -- GitLab