From bd735314150ced8120100514b735c550d6e7acb3 Mon Sep 17 00:00:00 2001 From: amajorek Date: Thu, 4 Mar 2010 23:54:47 -0500 Subject: [PATCH] py3k - more elegant s2b implementation --- tests/__init__.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/tests/__init__.py b/tests/__init__.py index e6fbc11..ff67be3 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -10,15 +10,9 @@ from eventlet import debug, hubs # convenience for importers main = unittest.main - -if sys.version_info[0]<3: - def s2b(string): - return string -else: - def s2b(string): - return bytes(string, 'latin1') - -s2b.__doc__ = """string to bytes. On 2.x no-op on 3.x encodes string in latin1""" +def s2b(s): + """portable way to convert string to bytes. In 3.x socket.send and recv require bytes""" + return s.encode() def skipped(func): """ Decorator that marks a function as skipped. Uses nose's SkipTest exception