jocxfin / pwgen

Simple self hosted password generator
GNU Affero General Public License v3.0
53 stars 3 forks source link

[BUG] `TypeError` indicating that 'BufferedReader' instances cannot be pickled #54

Closed jocxfin closed 6 months ago

jocxfin commented 6 months ago

Describe the bug An error occurs when attempting to cache objects using Flask-Caching with cachelib in a Flask application. The error is a TypeError indicating that 'BufferedReader' instances cannot be pickled.

To Reproduce Steps to reproduce the behavior:

  1. Use Flask-Caching with cachelib as the caching backend in a Flask application.
  2. Attempt to cache an object that includes or is a BufferedReader instance.
  3. Trigger the caching mechanism (e.g., by accessing a route that performs caching).
  4. See the error: TypeError: cannot pickle 'BufferedReader' instances

Expected behavior Objects, including those containing or being BufferedReader instances, should be serialized and cached without raising a TypeError. Alternatively, a more informative error or a mechanism to handle non-serializable objects gracefully should be provided.

Screenshots N/A

Desktop:

Additional context This issue may arise from the serialization process used by cachelib when caching objects. pickle.dumps() is used for serialization, which does not support BufferedReader instances. A potential workaround involves manually handling serialization for these instances or avoiding caching them directly.