From: Gregory Roussac Date: Thu, 25 Aug 2016 15:23:12 +0000 (+0200) Subject: VCR AttributeError: 'NoneType' object has no attribute 'encode' X-Git-Tag: v1.10.3~2^2~2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=9c275dd86aa8c204ecb24f3e417699520c4d821d;p=vcrpy.git VCR AttributeError: 'NoneType' object has no attribute 'encode' Hi, Using an old fork but may be usefull. I think checking the string is required like on line 47. Best regards --- diff --git a/vcr/serializers/compat.py b/vcr/serializers/compat.py index 0fcc583..8364997 100644 --- a/vcr/serializers/compat.py +++ b/vcr/serializers/compat.py @@ -24,7 +24,7 @@ def convert_body_to_bytes(resp): http://pyyaml.org/wiki/PyYAMLDocumentation#Python3support """ try: - if not isinstance(resp['body']['string'], six.binary_type): + if resp['body']['string'] is not None and not isinstance(resp['body']['string'], six.binary_type): resp['body']['string'] = resp['body']['string'].encode('utf-8') except (KeyError, TypeError, UnicodeEncodeError): # The thing we were converting either wasn't a dictionary or didn't