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

Function normalize_output

Lib/test/test_pty.py:46–64  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

44# and normalize_output can be used.
45
46def normalize_output(data):
47 # Some operating systems do conversions on newline. We could possibly fix
48 # that by doing the appropriate termios.tcsetattr()s. I couldn't figure out
49 # the right combo on Tru64. So, just normalize the output and doc the
50 # problem O/Ses by allowing certain combinations for some platforms, but
51 # avoid allowing other differences (like extra whitespace, trailing garbage,
52 # etc.)
53
54 # This is about the best we can do without getting some feedback
55 # from someone more knowledgable.
56
57 # OSF/1 (Tru64) apparently turns \n into \r\r\n.
58 if data.endswith(b'\r\r\n'):
59 return data.replace(b'\r\r\n', b'\n')
60
61 if data.endswith(b'\r\n'):
62 return data.replace(b'\r\n', b'\n')
63
64 return data
65
66def _readline(fd):
67 """Read one line. May block forever if no newline is read."""

Callers 1

test_openptyMethod · 0.85

Calls 2

endswithMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…