Skip to content

Commit

Permalink
Merge pull request #2354 from coder2020official/middlewares
Browse files Browse the repository at this point in the history
Use deepcopy instead of a shallow copy for middlewares, #2349
  • Loading branch information
Badiboy authored Aug 5, 2024
2 parents 5f9b5c7 + 74019d0 commit 96761f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion telebot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# random module to generate random string
import random
import string
import copy

import ssl

Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions telebot/async_telebot.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import string
import random
import ssl

import copy

"""
Module : telebot
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 96761f8

Please sign in to comment.