From: Kevin McCarthy Date: Sat, 10 May 2014 21:35:09 +0000 (-1000) Subject: add note about hack X-Git-Tag: v1.0.0~4 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=d7f7152dbf6c17ff6b5f2adae1e5328a3480dfb1;p=vcrpy.git add note about hack --- diff --git a/vcr/migration.py b/vcr/migration.py index 421be0c..0b36284 100644 --- a/vcr/migration.py +++ b/vcr/migration.py @@ -31,7 +31,19 @@ except ImportError: from yaml import Loader def preprocess_yaml(cassette): - return cassette.replace(' !!python/object:vcr.request.Request', '').replace('!!python/object/apply:__builtin__.frozenset', '').replace('!!python/object/apply:builtins.frozenset', '') + # this is the hack that makes the whole thing work. The old version used + # to deserialize to Request objects automatically using pyYaml's !!python + # tag system. This made it difficult to deserialize old cassettes on new + # versions. So this just strips the tags before deserializing. + + STRINGS_TO_NUKE = [ + '!!python/object:vcr.request.Request', + '!!python/object/apply:__builtin__.frozenset', + '!!python/object/apply:builtins.frozenset', + ] + for s in STRINGS_TO_NUKE: + cassette = cassette.replace(s, '') + return cassette PARTS = [