Skip to content

Commit

Permalink
temp: incorrect code to show a CPython bug
Browse files Browse the repository at this point in the history
The expression `bytes.decode()` is wrong, it should be
`original_filename.decode()`.  But this fails with:
```
TypeError: decode() takes at least 0 positional arguments (-1 given)
```
  • Loading branch information
nedbat committed May 2, 2023
1 parent e4931fe commit d8f52a2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions coverage/inorout.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,11 @@ def should_trace(self, filename: str, frame: Optional[FrameType] = None) -> TFil
"""
original_filename = filename
if isinstance(original_filename, bytes):
print(f"{original_filename = }")
from coverage.debug import dump_stack_frames
dump_stack_frames()
original_filename = original_filename.decode()
disp = disposition_init(self.disp_class, filename)

def nope(disp: TFileDisposition, reason: str) -> TFileDisposition:
Expand Down
2 changes: 1 addition & 1 deletion requirements/pins.pip
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
# checking the Python version like that, should it?
# https://github.com/pypa/packaging/issues/678
# https://github.com/nedbat/coveragepy/issues/1556
#setuptools<66.0.0
setuptools<66.0.0
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ toxworkdir = {env:TOXWORKDIR:.tox}
extras =
toml
package = editable
download = true

# PYVERSIONS
deps =
Expand Down

0 comments on commit d8f52a2

Please sign in to comment.