]> khamidou — GitHub mirrors - vcrpy.git/commitdiff
VCR AttributeError: 'NoneType' object has no attribute 'encode'
authorGregory Roussac <gRoussac@users.noreply.github.com>
Thu, 25 Aug 2016 15:23:12 +0000 (17:23 +0200)
committerKevin McCarthy <me@kevinmccarthy.org>
Sun, 2 Oct 2016 22:07:37 +0000 (12:07 -1000)
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

index 0fcc5833a6bc3e52c0ca152b73c82d8a6411f0e8..8364997529be0344f8d2a85fcfb6ad084bba6992 100644 (file)
@@ -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