From d7f7152dbf6c17ff6b5f2adae1e5328a3480dfb1 Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Sat, 10 May 2014 11:35:09 -1000 Subject: [PATCH] add note about hack --- vcr/migration.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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 = [