Don't use __code__

__code__ is a special method name used by python already
source:
https://docs.python.org/3/reference/datamodel.html#special-method-names
This commit is contained in:
Matthias 2020-09-26 16:33:48 +02:00
parent b38f68b3b0
commit 350fcc071e
3 changed files with 4 additions and 4 deletions

View File

@ -98,7 +98,7 @@ class IResolver:
if obj: if obj:
obj[0].__file__ = str(entry) obj[0].__file__ = str(entry)
if add_source: if add_source:
obj[0].__code__ = obj[1] obj[0].__source__ = obj[1]
return (obj[0], module_path) return (obj[0], module_path)
return (None, None) return (None, None)

View File

@ -608,7 +608,7 @@ class ApiServer(RPC):
return self.rest_dump({ return self.rest_dump({
'strategy': strategy_obj.get_strategy_name(), 'strategy': strategy_obj.get_strategy_name(),
'code': strategy_obj.__code__, 'code': strategy_obj.__source__,
}) })
@require_login @require_login

View File

@ -55,8 +55,8 @@ def test_load_strategy(default_conf, result):
'strategy_path': str(Path(__file__).parents[2] / 'freqtrade/templates') 'strategy_path': str(Path(__file__).parents[2] / 'freqtrade/templates')
}) })
strategy = StrategyResolver.load_strategy(default_conf) strategy = StrategyResolver.load_strategy(default_conf)
assert isinstance(strategy.__code__, str) assert isinstance(strategy.__source__, str)
assert 'class SampleStrategy' in strategy.__code__ assert 'class SampleStrategy' in strategy.__source__
assert isinstance(strategy.__file__, str) assert isinstance(strategy.__file__, str)
assert 'rsi' in strategy.advise_indicators(result, {'pair': 'ETH/BTC'}) assert 'rsi' in strategy.advise_indicators(result, {'pair': 'ETH/BTC'})