Skip to content

Commit 96761f8

Browse files
authored
Merge pull request #2354 from coder2020official/middlewares
Use deepcopy instead of a shallow copy for middlewares, #2349
2 parents 5f9b5c7 + 74019d0 commit 96761f8

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

telebot/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# random module to generate random string
2121
import random
2222
import string
23+
import copy
2324

2425
import ssl
2526

@@ -8756,7 +8757,7 @@ def _run_middlewares_and_handler(self, message, handlers, middlewares, update_ty
87568757
logger.error("It is not allowed to pass data and values inside data to the handler. Check your handler: {}".format(handler['function']))
87578758
return
87588759
else:
8759-
data_copy = data.copy()
8760+
data_copy = copy.deepcopy(data)
87608761
for key in list(data_copy):
87618762
# remove data from data_copy if handler does not accept it
87628763
if key not in params:

telebot/async_telebot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import string
3333
import random
3434
import ssl
35-
35+
import copy
3636

3737
"""
3838
Module : telebot
@@ -558,7 +558,7 @@ async def _run_middlewares_and_handlers(self, message, handlers, middlewares, up
558558
logger.error("It is not allowed to pass data and values inside data to the handler. Check your handler: {}".format(handler['function']))
559559
return
560560
else:
561-
data_copy = data.copy()
561+
data_copy = copy.deepcopy(data)
562562
for key in list(data_copy):
563563
# remove data from data_copy if handler does not accept it
564564
if key not in params:

0 commit comments

Comments
 (0)