Skip to content

Commit da9dfb7

Browse files
committed
gh-153569: remove unused source views and unrelated test cleanup
1 parent 5a4ec09 commit da9dfb7

3 files changed

Lines changed: 3 additions & 27 deletions

File tree

Modules/_testinternalcapi/tokenizer.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,9 @@ test_tokenizer_source(PyObject *Py_UNUSED(module),
5151
goto error;
5252
}
5353

54-
Py_ssize_t view_len;
55-
const char *view = _PyTok_SourceSpanView(
56-
&source, _PyTok_SpanFromBounds(6, 8), &view_len);
57-
if (check(view != NULL && view_len == 2 &&
58-
memcmp(view, "\xce\xb2", 2) == 0,
59-
"wrong source span view") < 0 ||
60-
check_system_error(
61-
_PyTok_SourceSpanView(
62-
&source, _PyTok_SpanFromBounds(0, source.len + 1),
63-
&view_len) == NULL,
64-
"accepted invalid source span") < 0) {
54+
if (check(source.len == 9 &&
55+
memcmp(source.bytes, "alpha\n\xce\xb2\n", 10) == 0,
56+
"wrong source contents") < 0) {
6557
goto error;
6658
}
6759

Parser/tokenizer/source.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -151,19 +151,6 @@ _PyTok_SourceAppendLine(_PyTok_SourceText *source, const char *bytes,
151151
return source->base_offset + start;
152152
}
153153

154-
const char *
155-
_PyTok_SourceSpanView(const _PyTok_SourceText *source, _PyTok_Span span,
156-
Py_ssize_t *len)
157-
{
158-
if (!_PyTok_SpanIsValid(span) || span.start < source->base_offset ||
159-
span.end - source->base_offset > source->len || len == NULL) {
160-
PyErr_SetString(PyExc_SystemError, "invalid tokenizer source span");
161-
return NULL;
162-
}
163-
*len = span.end - span.start;
164-
return _PyTok_SourceData(source) + (span.start - source->base_offset);
165-
}
166-
167154
int
168155
_PyTok_SourceLineIsImplicit(const _PyTok_SourceText *source, int lineno)
169156
{

Parser/tokenizer/source.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ PyAPI_FUNC(void) _PyTok_SourceDiscard(_PyTok_SourceText *);
4747
PyAPI_FUNC(_PyTok_Off) _PyTok_SourceAppendLine(
4848
_PyTok_SourceText *source, const char *bytes, Py_ssize_t len,
4949
int implicit_newline);
50-
/* The returned view is invalidated by SourceAppendLine and SourceClear. */
51-
PyAPI_FUNC(const char *) _PyTok_SourceSpanView(
52-
const _PyTok_SourceText *, _PyTok_Span, Py_ssize_t *);
5350
/* Return false for invalid line numbers and the virtual EOF line. */
5451
PyAPI_FUNC(int) _PyTok_SourceLineIsImplicit(
5552
const _PyTok_SourceText *, int);

0 commit comments

Comments
 (0)