From 9c275dd86aa8c204ecb24f3e417699520c4d821d Mon Sep 17 00:00:00 2001 From: Gregory Roussac Date: Thu, 25 Aug 2016 17:23:12 +0200 Subject: [PATCH] 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 --- vcr/serializers/compat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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