Skip to content

Commit b4b06a7

Browse files
authored
POST-ing binary files was failing (#95)
* Fix for #94. * Fix for Py2/3.4. * Migrating to using twine. * Version +=1.
1 parent d0ad06e commit b4b06a7

4 files changed

Lines changed: 134 additions & 120 deletions

File tree

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ safetest:
3131
export SKIP_TRUE_REDIS=1; export SKIP_TRUE_HTTP=1; make test
3232

3333
publish:
34-
python setup.py sdist upload
34+
python setup.py sdist
35+
pip install -U twine
36+
twine upload dist/mocket-$(shell python -c 'import mocket; print(mocket.__version__)').tar.gz
3537
pip install anaconda-client
3638
anaconda upload dist/mocket-$(shell python -c 'import mocket; print(mocket.__version__)').tar.gz
3739

mocket/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77

88
__all__ = (mocketize, Mocket, MocketEntry, Mocketizer)
99

10-
__version__ = '2.7.3'
10+
__version__ = '2.7.4'

mocket/compat.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import codecs
12
import os
2-
import sys
33
import shlex
4+
import sys
45

56
import six
67

7-
encoding = os.getenv("MOCKET_ENCODING", 'utf-8')
8+
encoding = os.getenv("MOCKET_ENCODING", "utf-8")
89

910
text_type = six.text_type
1011
byte_type = six.binary_type
@@ -28,6 +29,7 @@ def unquote_utf8(qs):
2829
else:
2930
from http.server import BaseHTTPRequestHandler
3031
from urllib.parse import urlsplit, parse_qs, unquote as unquote_utf8
32+
3133
FileNotFoundError = FileNotFoundError
3234

3335
try:
@@ -36,15 +38,15 @@ def unquote_utf8(qs):
3638
JSONDecodeError = ValueError
3739

3840

39-
def encode_to_bytes(s, charset=encoding):
41+
def encode_to_bytes(s, encoding=encoding):
4042
if isinstance(s, text_type):
41-
s = s.encode(charset)
43+
s = s.encode(encoding)
4244
return byte_type(s)
4345

4446

45-
def decode_from_bytes(s, charset=encoding):
47+
def decode_from_bytes(s, encoding=encoding):
4648
if isinstance(s, byte_type):
47-
s = s.decode(charset)
49+
s = codecs.decode(s, encoding, "ignore")
4850
return text_type(s)
4951

5052

0 commit comments

Comments
 (0)