From 471d805b45c04bb138facf48ad6f98e296bb75f4 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sat, 7 Jun 2014 22:17:28 +0300 Subject: [PATCH] http.client: Explicitly check for str type instead of "encode" method. MicroPython string type shares setup with bytes, and thus both have entries for "encode" and "decode" (but only one valid for a type really works). --- http.client/http/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http.client/http/client.py b/http.client/http/client.py index cc452e2f..e8eace6d 100644 --- a/http.client/http/client.py +++ b/http.client/http/client.py @@ -1037,7 +1037,7 @@ class HTTPConnection: header = header.encode('ascii') values = list(values) for i, one_value in enumerate(values): - if hasattr(one_value, 'encode'): + if isinstance(one_value, str): values[i] = one_value.encode('latin-1') elif isinstance(one_value, int): values[i] = str(one_value).encode('ascii')