You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
trace.CoverageResult fails merging input file with non-empty callers #51524
trace.CoverageResults expects arguments in the order "counts, calledfuncs,
infile, callers..." but the try statement in the last part of __init__
passes "counts, calledfuncs, callers" as positional arguments to a new
instance of the same class. Thus, the secondary instance erroneously
obtains a dict for the "infile" argument, so I propose passing "callers"
as a keyword argument to avoid this.
Not that this has gone unnoticed because an empty dict for the "infile"
argument evaluates to False in "if self.infile:", which must have been
intended as "if self.infile is not None:". If, however, the original
instance loads a pickle file with a non-empty "callers" argument, the
secondary instance tries to run "open({}, 'rb')", which yields:
TypeError: coercing to Unicode: need string or buffer, dict found
changed the title [-]CoverageResult fails to merge input file with non-empty callers in trace.py (patch)[/-][+]CoverageResult fails to merge input file with non-empty callers in trace.py[/+]on Apr 21, 2016
changed the title [-]CoverageResult fails to merge input file with non-empty callers in trace.py[/-][+]trace.CoverageResult fails merging input file with non-empty callers[/+]on Nov 20, 2022
Activity
glinsvad commentedon Nov 6, 2009
trace.CoverageResults expects arguments in the order "counts, calledfuncs,
infile, callers..." but the try statement in the last part of __init__
passes "counts, calledfuncs, callers" as positional arguments to a new
instance of the same class. Thus, the secondary instance erroneously
obtains a dict for the "infile" argument, so I propose passing "callers"
as a keyword argument to avoid this.
Not that this has gone unnoticed because an empty dict for the "infile"
argument evaluates to False in "if self.infile:", which must have been
intended as "if self.infile is not None:". If, however, the original
instance loads a pickle file with a non-empty "callers" argument, the
secondary instance tries to run "open({}, 'rb')", which yields:
TypeError: coercing to Unicode: need string or buffer, dict found
BreamoreBoy commentedon Jul 11, 2010
The attached patch is effectively a one liner.
berkerpeksag commentedon Apr 21, 2016
Thanks for the report and for the patch, Christian. Here is a patch with a test.
[-]CoverageResult fails to merge input file with non-empty callers in trace.py (patch)[/-][+]CoverageResult fails to merge input file with non-empty callers in trace.py[/+]iritkatriel commentedon Jan 20, 2022
The patch needs to be converted to a GitHub PR.
furkanonder commentedon Nov 20, 2022
@iritkatriel I opened a PR for this issue.
[-]CoverageResult fails to merge input file with non-empty callers in trace.py[/-][+]trace.CoverageResult fails merging input file with non-empty callers[/+]gh-51524: Fix bug when calling trace.CoverageResults with valid infile (
pythongh-51524: Fix bug when calling trace.CoverageResults with valid…
pythongh-51524: Fix bug when calling trace.CoverageResults with valid…
gh-51524: Fix bug when calling trace.CoverageResults with valid infile (
gh-51524: Fix bug when calling trace.CoverageResults with valid infile (