fbchat icon indicating copy to clipboard operation
fbchat copied to clipboard

Error when saving cookies in session_handling example

Open bwint opened this issue 6 years ago • 1 comments

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
  • fbchat version: 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

bwint avatar Apr 04 '20 09:04 bwint

Fixed by @xaadu in https://github.com/carpedm20/fbchat/pull/559, thanks for the report 👍

madsmtm avatar May 06 '20 09:05 madsmtm