cpython: 0a985f7c6731 (original) (raw)

Mercurial > cpython

changeset 104829:0a985f7c6731 3.6

Issue #28385: An error message when non-empty format spec is passed to object.__format__ now contains the name of actual type. [#28385]

Serhiy Storchaka storchaka@gmail.com
date Sun, 30 Oct 2016 19:37:46 +0200
parents f1abc92a756a(current diff)92cae79fa5d9(diff)
children 6e8183abcc35 de8e83262644
files Lib/test/test_builtin.py Lib/test/test_bytes.py Objects/typeobject.c
diffstat 3 files changed, 30 insertions(+), 33 deletions(-)[+] [-] Lib/test/test_builtin.py 24 Lib/test/test_bytes.py 9 Objects/typeobject.c 30

line wrap: on

line diff

--- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -11,6 +11,7 @@ import os import pickle import platform import random +import re import sys import traceback import types @@ -1447,21 +1448,14 @@ class BuiltinTest(unittest.TestCase): # -------------------------------------------------------------------- # Issue #7994: object.format with a non-empty format string is

-

-

class B: pass @@ -1470,8 +1464,12 @@ class BuiltinTest(unittest.TestCase): pass for cls in [object, B, C]:

# make sure we can take a subclass of str as a format spec

--- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -1416,6 +1416,15 @@ class AssortedBytesTest(unittest.TestCas self.assertEqual(f(b"'"), '''b"'"''') # ''' self.assertEqual(f(b"'""), r"""b''"'""") # '

+ def test_compare_bytes_to_bytearray(self): self.assertEqual(b"abc" == bytes(b"abc"), True) self.assertEqual(b"ab" != bytes(b"abc"), True)

--- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -4392,13 +4392,6 @@ PyDoc_STRVAR(object_init_subclass_doc, "The default implementation does nothing. It may be\n" "overridden to extend subclasses.\n"); -/*

-*/ static PyObject * object_format(PyObject *self, PyObject *args) { @@ -4409,22 +4402,19 @@ object_format(PyObject *self, PyObject * if (!PyArg_ParseTuple(args, "U:format", &format_spec)) return NULL;

- result = PyObject_Format(self_as_str, format_spec);

- -done:

-