From e3e79a55fa6fc1baedac19d8ff1b28af78391a97 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 12 Aug 2018 10:16:51 +0200 Subject: [PATCH] Fix _abc_data pickle error in 3.7 --- freqtrade/strategy/__init__.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/freqtrade/strategy/__init__.py b/freqtrade/strategy/__init__.py index 283426dfa..49b0c45c0 100644 --- a/freqtrade/strategy/__init__.py +++ b/freqtrade/strategy/__init__.py @@ -12,8 +12,18 @@ def import_strategy(strategy: IStrategy, config: dict) -> IStrategy: Imports given Strategy instance to global scope of freqtrade.strategy and returns an instance of it """ + # Copy all attributes from base class and class - attr = deepcopy({**strategy.__class__.__dict__, **strategy.__dict__}) + + comb = {**strategy.__class__.__dict__, **strategy.__dict__} + + # Delete '_abc_impl' from dict as deepcopy fails on 3.7 with + # `TypeError: can't pickle _abc_data objects`` + # This will only apply to python 3.7 + if '_abc_impl' in comb: + del comb['_abc_impl'] + + attr = deepcopy(comb) # Adjust module name attr['__module__'] = 'freqtrade.strategy'