bpo-41138: Fix trace CLI for non-UTF-8 files. (GH-21177)

Fix also a resource warning when store counts and module info.
3 files changed