summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_bytes.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-12-20 14:36:34 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-12-20 14:36:34 (GMT)
commit5aac3ed79999f6948d11f979ab3e42b9b60e9083 (patch)
treeb338eac95f23fe5bdebacc996986d43204621ac7 /Lib/test/test_bytes.py
parent5185597a69f1df8c68ba8d42fe39991124863488 (diff)
downloadcpython-5aac3ed79999f6948d11f979ab3e42b9b60e9083.zip
cpython-5aac3ed79999f6948d11f979ab3e42b9b60e9083.tar.gz
cpython-5aac3ed79999f6948d11f979ab3e42b9b60e9083.tar.bz2
Issue #25766: Special method __bytes__() now works in str subclasses.
Diffstat (limited to 'Lib/test/test_bytes.py')
-rw-r--r--Lib/test/test_bytes.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
index 8158f78..caf28fd 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -779,6 +779,12 @@ class BytesTest(BaseBytesTest, unittest.TestCase):
def __index__(self):
return 42
self.assertEqual(bytes(A()), b'a')
+ # Issue #25766
+ class A(str):
+ def __bytes__(self):
+ return b'abc'
+ self.assertEqual(bytes(A('\u20ac')), b'abc')
+ self.assertEqual(bytes(A('\u20ac'), 'iso8859-15'), b'\xa4')
# Issue #24731
class A:
def __bytes__(self):