8000 gh-123378: fix some corner cases of `start` and `end` values in `PyUnicodeErrorObject` by picnixz · Pull Request #123380 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-123378: fix some corner cases of start and end values in PyUnicodeErrorObject #123380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 34 commits into from
Dec 4, 2024
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7a1574d
Fix `PyUnicode{Encode,Decode}Error_GetStart`.
picnixz Aug 26, 2024
6ef0c6d
blurb
picnixz Aug 27, 2024
60ab0bb
add tests
picnixz Aug 27, 2024
67b3d8e
fix NEWS
picnixz Aug 27, 2024
78fff57
remove a duplicated normal case
picnixz Aug 27, 2024
a6e6f80
handle start < 0
picnixz Aug 28, 2024
20c47ba
add C tests
picnixz Aug 28, 2024
51bc77e
add test coverage
picnixz Aug 28, 2024
b290e58
update docs
picnixz Aug 28, 2024
75398a9
fixup
picnixz Aug 28, 2024
546be87
update blurb
picnixz Aug 28, 2024
cded571
address Victor's review
picnixz Aug 29, 2024
1900d9a
refactor name
picnixz Aug 29, 2024
8acc563
fix refcounts
picnixz Aug 29, 2024
0538c83
remove debugging code
picnixz Aug 29, 2024
d5ea357
address Victor's review (round 2)
picnixz Aug 29, 2024
7c10769
handle negative 'start' and 'end' values
picnixz Aug 30, 2024
7ce2ef0
add C API tests
picnixz Aug 30, 2024
b55ca5a
add Python tests
picnixz Aug 30, 2024
4e34e5f
update docs
picnixz Aug 30, 2024
033a1ac
fix typo
picnixz Aug 30, 2024
c802e64
convert macros into `static inline` functions
picnixz Sep 13, 2024
66f33f8
Merge branch 'main' into fix/c-api-unicode-error-get-start
skirpichev Sep 20, 2024
6caf5b6
Merge remote-tracking branch 'upstream/main' into fix/c-api-unicode-e…
picnixz Oct 27, 2024
fcde448
post-merge cleanup
picnixz Oct 27, 2024
2e66302
Merge branch 'main' into fix/capi/unicode-error-start-end-123378
picnixz Nov 19, 2024
dc6b37b
Merge branch 'main' into fix/capi/unicode-error-start-end-123378
picnixz Nov 29, 2024
baa5cb2
fix typo
picnixz Dec 2, 2024
4c4808e
update NEWS and docs
picnixz Dec 2, 2024
efbdff1
add some assertion checks
picnixz Dec 2, 2024
180f3c2
add some assertion checks
picnixz Dec 2, 2024
4bd6e20
Merge branch 'main' into fix/c-api-unicode-error-get-start
picnixz Dec 2, 2024
5759a70
remove failing assertions for now
picnixz Dec 3, 2024
8c12171
fix docs
picnixz Dec 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
post-merge cleanup
  • Loading branch information
picnixz committed Oct 27, 2024
commit fcde448436a38ca9ce55fcd5e395ac869262c2fb
26 changes: 0 additions & 26 deletions Objects/exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -2748,32 +2748,6 @@ unicode_error_adjust_end(Py_ssize_t end, Py_ssize_t objlen)
return end;
}

static inline int
unicode_error_is_single_bad_char(PyUnicodeErrorObject *exc)
{
// We use the 'start' and the 'end' values here and NOT those given
// by the corresponding getters since they clip the output. This is
// done to keep a behaviour since Python 3.1 (see gh-51558).
Py_ssize_t start = exc->start, end = exc->end;
return (
start >= 0 && start < PyUnicode_GET_LENGTH(exc->object) &&
end >= 0 && end == start + 1
);
}

static inline int
unicode_error_is_single_bad_byte(PyUnicodeErrorObject *exc)
{
// We use the 'start' and the 'end' values here and NOT those given
// by the corresponding getters since they clip the output. This is
// done to keep a behaviour since Python 3.1 (see gh-51558).
Py_ssize_t start = exc->start, end = exc->end;
return (
start >= 0 && start < PyBytes_GET_SIZE(exc->object) &&
end >= 0 && end == start + 1
);
}

PyObject *
PyUnicodeEncodeError_GetEncoding(PyObject *exc)
{
Expand Down
Loading
0