Skip to content

fix : replace pickle with json and add context managers in Word-Building data.py #1878

Description

@tmdeveloper007

Summary of What Needs to be Done

Fix games/Word-Building/data.py. The current implementation has three issues:

  1. Uses pickle.load() and pickle.dump() instead of JSON, which is a security risk (pickle can execute arbitrary code on deserialization)
  2. Does not use context managers (with statements), so files may not be properly closed if an exception occurs
  3. Module-level code at lines 19-21 executes pickle.load() at import time, which is a side effect that can crash imports if the file is corrupted

Changes that Need to be Made

Replace all pickle operations with json, use with statements for file operations, and wrap the module-level file reading in a try/except block or guard it with if __name__ == "__main__":.

Impact that it would Provide

Improved security (no pickle deserialization vulnerabilities), proper resource cleanup, and safe module imports even if the data file is corrupted.

Note: please assign this issue to the tmdeveloper007 account.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions