summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-12-20 14:37:21 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-12-20 14:37:21 (GMT)
commit3182db356c8e6106b7bdab907739c741c508037a (patch)
tree74503a2d8698fac210897f8a76a796497d0beb91 /Lib/test
parent5decf0bf325a7a2d85910e2580c10aa03c907efc (diff)
parent5aac3ed79999f6948d11f979ab3e42b9b60e9083 (diff)
downloadcpython-3182db356c8e6106b7bdab907739c741c508037a.zip
cpython-3182db356c8e6106b7bdab907739c741c508037a.tar.gz
cpython-3182db356c8e6106b7bdab907739c741c508037a.tar.bz2
Issue #25766: Special method __bytes__() now works in str subclasses.
Diffstat (limited to 'Lib/test')
-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 cc951cf..e813190 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -793,6 +793,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):