MCPcopy Index your code
hub / github.com/python/cpython / contains_ambiguous_backslash

Function contains_ambiguous_backslash

Lib/test/test_tokenize.py:1978–1991  ·  view source on GitHub ↗

Return `True` if the source contains a backslash on a line by itself. For example: a = (1 \\ ) Code like this cannot be untokenized exactly. This is because the tokenizer does not produce any tokens for the line containing the backslash and so there is no way to kno

(source)

Source from the content-addressed store, hash-verified

1976
1977
1978def contains_ambiguous_backslash(source):
1979 """Return `True` if the source contains a backslash on a
1980 line by itself. For example:
1981
1982 a = (1
1983 \\
1984 )
1985
1986 Code like this cannot be untokenized exactly. This is because
1987 the tokenizer does not produce any tokens for the line containing
1988 the backslash and so there is no way to know its indent.
1989 """
1990 pattern = re.compile(br'\n\s*\\\r?\n')
1991 return pattern.search(source) is not None
1992
1993
1994class TestRoundtrip(TestCase):

Callers 1

check_roundtripMethod · 0.85

Calls 2

compileMethod · 0.45
searchMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…