Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b487e63

Browse files
committed
stringio doesn't have an encoding
1 parent 16f966e commit b487e63

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

Lib/_pyio.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,3 +1834,7 @@ def __repr__(self):
18341834
# TextIOWrapper tells the encoding in its repr. In StringIO,
18351835
# that's a implementation detail.
18361836
return object.__repr__(self)
1837+
1838+
@property
1839+
def encoding(self):
1840+
return None

Lib/test/test_memoryio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ def test_textio_properties(self):
451451

452452
# These are just dummy values but we nevertheless check them for fear
453453
# of unexpected breakage.
454-
self.assertEqual(memio.encoding, "utf-8")
454+
self.assertTrue(memio.encoding is None)
455455
self.assertEqual(memio.errors, "strict")
456456
self.assertEqual(memio.line_buffering, False)
457457

Modules/_stringio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ stringio_encoding(StringIOObject *self, void *context)
665665
{
666666
CHECK_INITIALIZED(self);
667667
CHECK_CLOSED(self);
668-
return PyUnicode_FromString("utf-8");
668+
Py_RETURN_NONE;
669669
}
670670

671671
static PyObject *

0 commit comments

Comments
 (0)