{"action":"created","issue":{"url":"https://api.github.com/repos/eternnoir/pyTelegramBotAPI/issues/559","repository_url":"https://api.github.com/repos/eternnoir/pyTelegramBotAPI","labels_url":"https://api.github.com/repos/eternnoir/pyTelegramBotAPI/issues/559/labels{/name}","comments_url":"https://api.github.com/repos/eternnoir/pyTelegramBotAPI/issues/559/comments","events_url":"https://api.github.com/repos/eternnoir/pyTelegramBotAPI/issues/559/events","html_url":"https://github.com/eternnoir/pyTelegramBotAPI/issues/559","id":350187378,"node_id":"MDU6SXNzdWUzNTAxODczNzg=","number":559,"title":"Deepcopy of handlers brings error","user":{"login":"Badiboy","id":5613421,"node_id":"MDQ6VXNlcjU2MTM0MjE=","avatar_url":"https://avatars2.githubusercontent.com/u/5613421?v=4","gravatar_id":"","url":"https://api.github.com/users/Badiboy","html_url":"https://github.com/Badiboy","followers_url":"https://api.github.com/users/Badiboy/followers","following_url":"https://api.github.com/users/Badiboy/following{/other_user}","gists_url":"https://api.github.com/users/Badiboy/gists{/gist_id}","starred_url":"https://api.github.com/users/Badiboy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Badiboy/subscriptions","organizations_url":"https://api.github.com/users/Badiboy/orgs","repos_url":"https://api.github.com/users/Badiboy/repos","events_url":"https://api.github.com/users/Badiboy/events{/privacy}","received_events_url":"https://api.github.com/users/Badiboy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-08-13T20:45:28Z","updated_at":"2018-08-13T20:46:14Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"_1. What version of pyTelegramBotAPI are you using?_\r\n3.6.5\r\n_2. What OS are you using?_\r\nWin10 / Ubuntu 14.x\r\n_3. What version of python are you using?_\r\n3.5.3\r\n\r\nWhen migrated from version 3.6.3 to 3.6.5 I got the following error:\r\n```\r\n2018-08-13 23:18:02,280 (__init__.py:313 PollingThread) DEBUG - TeleBot: \"Received 1 new updates\"\r\n2018-08-13 23:18:02,298 (util.py:65 PollingThread) ERROR - TeleBot: \"TypeError occurred, args=(\"cannot serialize '_io.TextIOWrapper' object\",)\r\nTraceback (most recent call last):\r\n  File \"C:\\Python3\\lib\\site-packages\\telebot\\util.py\", line 59, in run\r\n    task(*args, **kwargs)\r\n  File \"C:\\Python3\\lib\\site-packages\\telebot\\__init__.py\", line 278, in __retrieve_updates\r\n    self.process_new_updates(updates)\r\n  File \"C:\\Python3\\lib\\site-packages\\telebot\\__init__.py\", line 315, in process_new_updates\r\n    self.process_new_messages(new_messages)\r\n  File \"C:\\Python3\\lib\\site-packages\\telebot\\__init__.py\", line 334, in process_new_messages\r\n    self._notify_next_handlers(new_messages)\r\n  File \"C:\\Python3\\lib\\site-packages\\telebot\\__init__.py\", line 1291, in _notify_next_handlers\r\n    handlers = copy.deepcopy(self.next_step_handlers[chat_id])\r\n  File \"C:\\Python3\\lib\\copy.py\", line 155, in deepcopy\r\n    y = copier(x, memo)\r\n  File \"C:\\Python3\\lib\\copy.py\", line 218, in _deepcopy_list\r\n    y.append(deepcopy(a, memo))\r\n  File \"C:\\Python3\\lib\\copy.py\", line 182, in deepcopy\r\n    y = _reconstruct(x, rv, 1, memo)\r\n  File \"C:\\Python3\\lib\\copy.py\", line 297, in _reconstruct\r\n    state = deepcopy(state, memo)\r\n  File \"C:\\Python3\\lib\\copy.py\", line 155, in deepcopy\r\n    y = copier(x, memo)\r\n  File \"C:\\Python3\\lib\\copy.py\", line 243, in _deepcopy_dict\r\n    y[deepcopy(key, memo)] = deepcopy(value, memo)\r\n  File \"C:\\Python3\\lib\\copy.py\", line 155, in deepcopy\r\n    y = copier(x, memo)\r\n  File \"C:\\Python3\\lib\\copy.py\", line 250, in _deepcopy_method\r\n    return type(x)(x.__func__, deepcopy(x.__self__, memo))\r\n  File \"C:\\Python3\\lib\\copy.py\", line 182, in deepcopy\r\n    y = _reconstruct(x, rv, 1, memo)\r\n  File \"C:\\Python3\\lib\\copy.py\", line 297, in _reconstruct\r\n    state = deepcopy(state, memo)\r\n  File \"C:\\Python3\\lib\\copy.py\", line 155, in deepcopy\r\n    y = copier(x, memo)\r\n  File \"C:\\Python3\\lib\\copy.py\", line 243, in _deepcopy_dict\r\n    y[deepcopy(key, memo)] = deepcopy(value, memo)\r\n  File \"C:\\Python3\\lib\\copy.py\", line 182, in deepcopy\r\n    y = _reconstruct(x, rv, 1, memo)\r\n  File \"C:\\Python3\\lib\\copy.py\", line 297, in _reconstruct\r\n    state = deepcopy(state, memo)\r\n  File \"C:\\Python3\\lib\\copy.py\", line 155, in deepcopy\r\n    y = copier(x, memo)\r\n  File \"C:\\Python3\\lib\\copy.py\", line 243, in _deepcopy_dict\r\n    y[deepcopy(key, memo)] = deepcopy(value, memo)\r\n  File \"C:\\Python3\\lib\\copy.py\", line 182, in deepcopy\r\n    y = _reconstruct(x, rv, 1, memo)\r\n  File \"C:\\Python3\\lib\\copy.py\", line 297, in _reconstruct\r\n    state = deepcopy(state, memo)\r\n  File \"C:\\Python3\\lib\\copy.py\", line 155, in deepcopy\r\n    y = copier(x, memo)\r\n  File \"C:\\Python3\\lib\\copy.py\", line 243, in _deepcopy_dict\r\n    y[deepcopy(key, memo)] = deepcopy(value, memo)\r\n  File \"C:\\Python3\\lib\\copy.py\", line 182, in deepcopy\r\n    y = _reconstruct(x, rv, 1, memo)\r\n  File \"C:\\Python3\\lib\\copy.py\", line 297, in _reconstruct\r\n    state = deepcopy(state, memo)\r\n  File \"C:\\Python3\\lib\\copy.py\", line 155, in deepcopy\r\n    y = copier(x, memo)\r\n  File \"C:\\Python3\\lib\\copy.py\", line 243, in _deepcopy_dict\r\n    y[deepcopy(key, memo)] = deepcopy(value, memo)\r\n  File \"C:\\Python3\\lib\\copy.py\", line 155, in deepcopy\r\n    y = copier(x, memo)\r\n  File \"C:\\Python3\\lib\\copy.py\", line 218, in _deepcopy_list\r\n    y.append(deepcopy(a, memo))\r\n  File \"C:\\Python3\\lib\\copy.py\", line 182, in deepcopy\r\n    y = _reconstruct(x, rv, 1, memo)\r\n  File \"C:\\Python3\\lib\\copy.py\", line 297, in _reconstruct\r\n    state = deepcopy(state, memo)\r\n  File \"C:\\Python3\\lib\\copy.py\", line 155, in deepcopy\r\n    y = copier(x, memo)\r\n  File \"C:\\Python3\\lib\\copy.py\", line 243, in _deepcopy_dict\r\n    y[deepcopy(key, memo)] = deepcopy(value, memo)\r\n  File \"C:\\Python3\\lib\\copy.py\", line 174, in deepcopy\r\n    rv = reductor(4)\r\nTypeError: cannot serialize '_io.TextIOWrapper' object\r\n```\r\nThe same error for thread.lock.\r\n```\r\n2018-08-13 23:07:34,291 (__init__.py:313 PollingThread) DEBUG - TeleBot: \"Received 1 new updates\"\r\n2018-08-13 23:07:34,305 (util.py:65 PollingThread) ERROR - TeleBot: \"TypeError occurred, args=(\"can't pickle _thread.lock objects\",)\r\nTraceback (most recent call last):\r\n  File \"C:\\Python3\\lib\\site-packages\\telebot\\util.py\", line 59, in run\r\n    task(*args, **kwargs)\r\n...\r\nTypeError: can't pickle _thread.lock objects\r\n```\r\n\r\nThe problem is strange for me. I use the thread.lock (the only place) in the method used in some message processing methods (including some used in **register_next_step** ) in the next way:\r\n```\r\ndef processing_method\r\n  call static_class_method(my_user_class)\r\n    my_user_class.locker.acquire()\r\n    ...\r\n    my_user_class.locker.release()\r\n```\r\nAnd for '_io.TextIOWrapper' I have no ideas where it happens."},"comment":{"url":"https://api.github.com/repos/eternnoir/pyTelegramBotAPI/issues/comments/412658128","html_url":"https://github.com/eternnoir/pyTelegramBotAPI/issues/559#issuecomment-412658128","issue_url":"https://api.github.com/repos/eternnoir/pyTelegramBotAPI/issues/559","id":412658128,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMjY1ODEyOA==","user":{"login":"Badiboy","id":5613421,"node_id":"MDQ6VXNlcjU2MTM0MjE=","avatar_url":"https://avatars2.githubusercontent.com/u/5613421?v=4","gravatar_id":"","url":"https://api.github.com/users/Badiboy","html_url":"https://github.com/Badiboy","followers_url":"https://api.github.com/users/Badiboy/followers","following_url":"https://api.github.com/users/Badiboy/following{/other_user}","gists_url":"https://api.github.com/users/Badiboy/gists{/gist_id}","starred_url":"https://api.github.com/users/Badiboy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Badiboy/subscriptions","organizations_url":"https://api.github.com/users/Badiboy/orgs","repos_url":"https://api.github.com/users/Badiboy/repos","events_url":"https://api.github.com/users/Badiboy/events{/privacy}","received_events_url":"https://api.github.com/users/Badiboy/received_events","type":"User","site_admin":false},"created_at":"2018-08-13T20:46:14Z","updated_at":"2018-08-13T20:46:14Z","author_association":"CONTRIBUTOR","body":"PS: I know that deepcopy appears in commit https://github.com/eternnoir/pyTelegramBotAPI/commit/494b535a9127c769401791c8acb7a1d1443560a0 deveoped by @Andru1999 . So I kindly call him to this thread."}}
{"actor":{"display_login":"Badiboy"}}