diff --git a/telebot/__init__.py b/telebot/__init__.py index 70d59ddde..97c3ea23c 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -20,6 +20,7 @@ # random module to generate random string import random import string +import copy import ssl @@ -8756,7 +8757,7 @@ def _run_middlewares_and_handler(self, message, handlers, middlewares, update_ty logger.error("It is not allowed to pass data and values inside data to the handler. Check your handler: {}".format(handler['function'])) return else: - data_copy = data.copy() + data_copy = copy.deepcopy(data) for key in list(data_copy): # remove data from data_copy if handler does not accept it if key not in params: diff --git a/telebot/async_telebot.py b/telebot/async_telebot.py index e702487f3..66ba987fb 100644 --- a/telebot/async_telebot.py +++ b/telebot/async_telebot.py @@ -32,7 +32,7 @@ import string import random import ssl - +import copy """ Module : telebot @@ -558,7 +558,7 @@ async def _run_middlewares_and_handlers(self, message, handlers, middlewares, up logger.error("It is not allowed to pass data and values inside data to the handler. Check your handler: {}".format(handler['function'])) return else: - data_copy = data.copy() + data_copy = copy.deepcopy(data) for key in list(data_copy): # remove data from data_copy if handler does not accept it if key not in params: