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
I think it is initialized to None and there seems to be nothing wrong with it, after all, int and str are a class.
This is not the issue. The issue concerns typing and the fact that errors must be typed str | None in this case, instead of just str. As for whether having a None value makes sense at runtime except for default-detection, the question remains and may affect existing users as Nikita hinted.
Bug report
Bug description:
See the exact line here:
cpython/Lib/tarfile.py
Line 1687 in ee57221
After that the errors is used only as string in encode/decode. And is initialized in the dunder init with default
errors="surrogateescape"
.So perhaps it would be a good idea to use
errors=""
in #L1687 ? or directly with the defaulterrors="surrogateescape"
?This was discovered as part of the typeshed, where
tarfile.TarFile.errors
was added into the allowed list since mypy complained: https://github.com/python/typeshed/blob/2ccc53bb6716463680fcf1d204642c46299b7f88/stdlib/%40tests/stubtest_allowlists/common.txt#L46C1-L46C16I will add a PR here and to the typeshed if this gets approved.
CPython versions tested on:
3.13
Operating systems tested on:
Windows
The text was updated successfully, but these errors were encountered: