Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Lib/test/test_bytes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""

import array
import operator
import os
import re
import sys
Expand Down Expand Up @@ -751,6 +752,8 @@ def check(fmt, vals, result):
check(b'%i%b %*.*b', (10, b'3', 5, 3, b'abc',), b'103 abc')
check(b'%c', b'a', b'a')

self.assertRaisesRegex(TypeError, '%i format: a real number is required, not complex', operator.mod, '%i', 2j)

def test_imod(self):
b = self.type2test(b'hello, %b!')
orig = b
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix error message when formatting bytes using the ``'i'`` flag.
Patch by Maxim Ageev.
2 changes: 0 additions & 2 deletions Objects/bytesobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,6 @@ static PyObject *
formatlong(PyObject *v, int flags, int prec, int type)
{
PyObject *result, *iobj;
if (type == 'i')
type = 'd';
if (PyLong_Check(v))
return _PyUnicode_FormatLong(v, flags & F_ALT, prec, type);
if (PyNumber_Check(v)) {
Expand Down
Loading