Issue #20435: Fix _pyio.StringIO.getvalue() to take into account newline translation settings.
diff --git a/Lib/_pyio.py b/Lib/_pyio.py
index a9b0064..9a2a1aa 100644
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -2060,7 +2060,13 @@
 
     def getvalue(self):
         self.flush()
-        return self.buffer.getvalue().decode(self._encoding, self._errors)
+        decoder = self._decoder or self._get_decoder()
+        old_state = decoder.getstate()
+        decoder.reset()
+        try:
+            return decoder.decode(self.buffer.getvalue(), final=True)
+        finally:
+            decoder.setstate(old_state)
 
     def __repr__(self):
         # TextIOWrapper tells the encoding in its repr. In StringIO,