mirror of
https://github.com/python/cpython.git
synced 2025-08-16 06:40:56 +00:00
Merged revisions 79278,79280 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r79278 | victor.stinner | 2010-03-22 13:24:37 +0100 (lun., 22 mars 2010) | 2 lines Issue #1583863: An unicode subclass can now override the __str__ method ........ r79280 | victor.stinner | 2010-03-22 13:36:28 +0100 (lun., 22 mars 2010) | 5 lines Fix the NEWS about my last commit: an unicode subclass can now override the __unicode__ method (and not the __str__ method). Simplify also the testcase. ........
This commit is contained in:
parent
974dd58372
commit
4fd2ff90a4
3 changed files with 12 additions and 1 deletions
|
@ -1142,6 +1142,15 @@ class UnicodeTest(
|
||||||
self.assertRaises(MemoryError, alloc)
|
self.assertRaises(MemoryError, alloc)
|
||||||
self.assertRaises(MemoryError, alloc)
|
self.assertRaises(MemoryError, alloc)
|
||||||
|
|
||||||
|
def test_format_subclass(self):
|
||||||
|
class U(unicode):
|
||||||
|
def __unicode__(self):
|
||||||
|
return u'__unicode__ overridden'
|
||||||
|
u = U(u'xxx')
|
||||||
|
self.assertEquals("%s" % u, u'__unicode__ overridden')
|
||||||
|
self.assertEquals("{0}".format(u), u'__unicode__ overridden')
|
||||||
|
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
test_support.run_unittest(__name__)
|
test_support.run_unittest(__name__)
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@ What's New in Python 2.6.6 alpha 1?
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #1583863: An unicode subclass can now override the __unicode__ method
|
||||||
|
|
||||||
- Issue #7544: Preallocate thread memory before creating the thread to avoid
|
- Issue #7544: Preallocate thread memory before creating the thread to avoid
|
||||||
a fatal error in low memory condition.
|
a fatal error in low memory condition.
|
||||||
|
|
||||||
|
|
|
@ -8653,7 +8653,7 @@ PyObject *PyUnicode_Format(PyObject *format,
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
case 'r':
|
case 'r':
|
||||||
if (PyUnicode_Check(v) && c == 's') {
|
if (PyUnicode_CheckExact(v) && c == 's') {
|
||||||
temp = v;
|
temp = v;
|
||||||
Py_INCREF(temp);
|
Py_INCREF(temp);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue