[2.7] [3.5] bpo-30070: Fixed leaks and crashes in errors handling in the parser module. (GH-1131). (GH-1185) (#1189)

(cherry picked from commit a79f4c219531c05fc8f670c1e4bbf12c081935d3).
(cherry picked from commit 952a05e4e2cf082b74a1676a2804f1f43a9b7702)
3 files changed