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

Function make_escapes

Tools/i18n/pygettext.py:187–203  ·  view source on GitHub ↗
(pass_nonascii)

Source from the content-addressed store, hash-verified

185
186
187def make_escapes(pass_nonascii):
188 global escapes, escape
189 if pass_nonascii:
190 # Allow non-ascii characters to pass through so that e.g. 'msgid
191 # "Höhe"' would not result in 'msgid "H\366he"'. Otherwise we
192 # escape any character outside the 32..126 range.
193 escape = escape_ascii
194 else:
195 escape = escape_nonascii
196 escapes = [fr"\{i:03o}" for i in range(256)]
197 for i in range(32, 127):
198 escapes[i] = chr(i)
199 escapes[ord('\\')] = r'\\'
200 escapes[ord('\t')] = r'\t'
201 escapes[ord('\r')] = r'\r'
202 escapes[ord('\n')] = r'\n'
203 escapes[ord('\"')] = r'\"'
204
205
206def escape_ascii(s, encoding):

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…