fbchat
fbchat copied to clipboard
Error when saving cookies in session_handling example
Description of the problem
When using the example for session_handling I noticed that I always got the following error trying to save the cookies to the session.json file.
Error:
Object of type 'TextIOWrapper' is not JSON serializable
Code to reproduce
def save_cookies(filename, cookies):
with open(filename, "w") as f:
json.dump(f, cookies)
Environment information
- Python version: 3.8
fbchatversion: fbchat-2.0.0a2
My Solution
def save_cookies(filename, cookies):
with open(filename, "w") as f:
json.dump(cookies, f)
According to the docs the json obj must be the firs parameter of the json.dumps function.
Would be nice to correct it in the example file:
examples/session_handling.py
Fixed by @xaadu in https://github.com/carpedm20/fbchat/pull/559, thanks for the report 👍