Git Product home page Git Product logo

Comments (7)

ping avatar ping commented on May 27, 2024

Doesn't pickle.dumps return a string? https://docs.python.org/2/library/pickle.html#pickle.dumps

I haven't had any problems saving the pickled string to a json file. I even wrote an example here https://github.com/ping/instagram_private_api/blob/master/examples/savesettings_logincallback.py based off how I save my settings. Does that not work for you?

from instagram_private_api.

wlerin avatar wlerin commented on May 27, 2024

pickle.dumps always returns bytes, the difference is that in Python 2, bytes is also str and gets automagically handled by the interpreter. In Python 3 with your example you get this instead:

TypeError: Object of type 'bytes' is not JSON serializable

from instagram_private_api.

ping avatar ping commented on May 27, 2024

Thanks for the catch. Please submit your changes in a PR and I'll get it merged.

from instagram_private_api.

wlerin avatar wlerin commented on May 27, 2024

It's actually possible to solve my original issue by just adding a .decode("utf-8") here.

I still think letting cookies be saved and restored as dicts is a useful feature, but it's not absolutely necessary to solve this problem.

from instagram_private_api.

ping avatar ping commented on May 27, 2024

Does that work for you?

I gave it a quick test but got
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte

With Py3.5.1

from instagram_private_api.

wlerin avatar wlerin commented on May 27, 2024

edit: Ah. I hadn't noticed 1de421a This works better now.

from instagram_private_api.

wlerin avatar wlerin commented on May 27, 2024

I'm going to keep refining and testing a CookieJar that accepts both dicts and str|bytes, but until then I'm closing this PR as the new changes are sufficient for saving to JSON.

from instagram_private_api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.