| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 929afd1 commit 7c3692f
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,7 @@ | |||
| 5 | 5 | """ | |
| 6 | 6 | ||
| 7 | 7 | import array | |
| 8 | + import operator | ||
| 8 | 9 | import os | |
| 9 | 10 | import re | |
| 10 | 11 | import sys | |
@@ -771,6 +772,9 @@ def check(fmt, vals, result): | |||
| 771 | 772 | check(b'%i%b %*.*b', (10, b'3', 5, 3, b'abc',), b'103 abc') | |
| 772 | 773 | check(b'%c', b'a', b'a') | |
| 773 | 774 | ||
| 775 | + self.assertRaisesRegex(TypeError, '%i format: a real number is required, not complex', operator.mod, '%i', 2j) | ||
| 776 | + self.assertRaisesRegex(TypeError, '%d format: a real number is required, not complex', operator.mod, '%d', 2j) | ||
| 777 | + | ||
| 774 | 778 | def test_imod(self): | |
| 775 | 779 | b = self.type2test(b'hello, %b!') | |
| 776 | 780 | orig = b | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -283,6 +283,10 @@ def test_common_format(self): | |||
| 283 | 283 | "%x format: an integer is required, not str") | |
| 284 | 284 | test_exc_common('%x', 3.14, TypeError, | |
| 285 | 285 | "%x format: an integer is required, not float") | |
| 286 | + test_exc_common('%i', '1', TypeError, | ||
| 287 | + "%i format: a real number is required, not str") | ||
| 288 | + test_exc_common('%i', b'1', TypeError, | ||
| 289 | + "%i format: a real number is required, not bytes") | ||
| 286 | 290 | ||
| 287 | 291 | def test_str_format(self): | |
| 288 | 292 | testformat("%r", "\u0378", "'\\u0378'") # non printable | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,2 @@ | |||
| 1 | + Fix error message when formatting bytes using the ``'i'`` flag. | ||
| 2 | + Patch by Maxim Ageev. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -469,8 +469,6 @@ static PyObject * | |||
| 469 | 469 | formatlong(PyObject *v, int flags, int prec, int type) | |
| 470 | 470 | { | |
| 471 | 471 | PyObject *result, *iobj; | |
| 472 | - if (type == 'i') | ||
| 473 | - type = 'd'; | ||
| 474 | 472 | if (PyLong_Check(v)) | |
| 475 | 473 | return _PyUnicode_FormatLong(v, flags & F_ALT, prec, type); | |
| 476 | 474 | if (PyNumber_Check(v)) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments