$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · medium · #185

Which fix removes the bug?

import json
data = json.load(open(path))
  1. Open inside a with block
  2. Use json.loads on text
  3. Pass encoding to open
  4. Catch a decode error
The file handle is never closed, so descriptors leak until the collector happens to run.
Play Problem Solving ▸