Commit Graph

94 Commits

Author SHA1 Message Date
Zackery Spytz 9654592478
bpo-42506: Fix unexpected output in test_format (GH-23564) 2020-11-30 17:39:12 +09:00
Lysandros Nikolaou 301822859b
bpo-42224: Fix test_format when locale does not expect number grouping (GH-23067) 2020-11-02 17:27:30 +02:00
han-solo 749ed85e44
Fixed mistake in test for f-string error description (GH-22036) (GH-22059) 2020-09-02 04:56:37 -04:00
han-solo 0d6aa7f0ee
bpo-41681: Fix for `f-string/str.format` error description when using 2 `,` in format specifier (GH-22036)
* Fixed `f-string/str.format` error description when using two `,` in format specifier.

Co-authored-by: millefalcon <hanish0019@hmail.com>
2020-09-01 10:34:29 -04:00
Mark Dickinson 895c9c1d43
bpo-40780: Fix failure of _Py_dg_dtoa to remove trailing zeros (GH-20435)
* Fix failure of _Py_dg_dtoa to remove trailing zeros

* Add regression test and news entry

* Add explanation about why it's safe to strip trailing zeros

* Make code safer, clean up comments, add change note at top of file

* Nitpick: avoid implicit int-to-float conversion in tests
2020-05-29 14:23:57 +01:00
Min ho Kim 39d87b5471 Fix typos mostly in comments, docs and test names (GH-15209) 2019-08-30 16:21:19 -04:00
Xiang Zhang 7e2a54cdd9 bpo-28856: Let %b format for bytes support objects that follow the buffer protocol (GH-546) 2017-03-14 15:07:15 +08:00
Serhiy Storchaka 9f8ad3f39e bpo-29568: Disable any characters between two percents for escaped percent "%%" in the format string for classic string formatting. (GH-513) 2017-03-08 11:51:19 +08:00
Serhiy Storchaka b7fc5e42c5 Issue #29073: Added a test for bytearray formatting with null byte. 2016-12-28 09:56:52 +02:00
Serhiy Storchaka c9ad8b7a23 Issue #29073: bytearray formatting no longer truncates on first null byte. 2016-12-28 09:54:22 +02:00
Serhiy Storchaka 025f8953f1 Issue #29000: Fixed bytes formatting of octals with zero padding in alternate
form.
2016-12-17 22:13:05 +02:00
Serhiy Storchaka b1a1619bf0 Issue #29000: Fixed bytes formatting of octals with zero padding in alternate
form.
2016-12-17 21:48:03 +02:00
Martin Panter 0a7b8596c0 Issues #28916, #26483: Merge stdtypes.rst from 3.5 2016-12-11 02:31:32 +00:00
Martin Panter 41176ae1d2 Issue #28916: Correct description of %o and %x alternative forms
* In Python 3, the specifier is 0o
* There is no special case for leading zeros
* Remove duplicate tests
* Clarify other existing tests and comments
2016-12-11 01:07:29 +00:00
Serhiy Storchaka 6db1f6f7ae Issue #26983: Fixed test_format failure.
Patch by SilentGhost.
2016-06-06 13:00:03 +03:00
Victor Stinner 0cdad1e2bc Issue #25349: Add fast path for b'%c' % int
Optimize also %% formater.
2015-10-09 22:50:36 +02:00
Serhiy Storchaka de1c27feaa Issue #23466: Fixed expected error message in test_format. 2015-04-04 17:29:28 +03:00
Serhiy Storchaka 41525e31a5 Issue #23466: Raised OverflowError if %c argument is out of range. 2015-04-03 20:53:46 +03:00
Serhiy Storchaka 2c7b5a9d0d Issue #23466: %c, %o, %x, and %X in bytes formatting now raise TypeError on
non-integer input.
2015-03-30 09:19:08 +03:00
Ethan Furman 62e977f1b6 Close issue23467: add %r compatibility to bytes and bytearray 2015-03-11 08:17:00 -07:00
Ethan Furman b95b56150f Issue20284: Implement PEP461 2015-01-23 20:05:18 -08:00
Ethan Furman 38d872ee5d Issue19995: passing a non-int to %o, %c, %x, or %X now raises an exception 2014-03-19 08:38:52 -07:00
Serhiy Storchaka f28ba369dd Issue #20532: Tests which use _testcapi now are marked as CPython only. 2014-02-07 10:10:55 +02:00
Serhiy Storchaka 5cfc79deae Issue #20532: Tests which use _testcapi now are marked as CPython only. 2014-02-07 10:06:39 +02:00
Serhiy Storchaka a146bef02b Catch deprecation warnings emitted when non-integers are formatted with %c, %o
and %x (introduced in issue #19995).
2014-02-06 22:44:27 +02:00
Ethan Furman f9bba9c67f Issue19995: issue deprecation warning for non-integer values to %c, %o, %x, %X 2014-01-11 23:20:58 -08:00
Ethan Furman df3ed242c0 Issue19995: %o, %x, %X now only accept ints 2014-01-05 06:50:30 -08:00
Mark Dickinson ed7bb488b4 Remove failing checks for explicit error messages. 2013-10-13 11:34:01 +01:00
Mark Dickinson ef8627b3f0 Issue #18659: fix test_format test that wasn't being executed. Thanks Vajrasky Kok for the patch. 2013-10-13 11:04:36 +01:00
Mark Dickinson f3e4b62d02 Issue #18659: Backed out changeset cfd875bcbe41 after buildbot failures. 2013-08-05 10:59:36 +01:00
Mark Dickinson a9e626f704 Issue #18659: fix test_format test that wasn't being executed. Thanks Vajrasky Kok for the patch. 2013-08-05 10:30:14 +01:00
Victor Stinner 2ab07f01a4 (Merge 3.3) Issue #18137: Detect integer overflow on precision in
float.__format__() and complex.__format__().
2013-06-23 14:55:43 +02:00
Victor Stinner 2f084ecfe7 Issue #18137: Detect integer overflow on precision in float.__format__() and
complex.__format__().
2013-06-23 14:54:30 +02:00
Victor Stinner cfc4c13b04 Add _PyUnicodeWriter_WriteSubstring() function
Write a function to enable more optimizations:

 * If the substring is the whole string and overallocation is disabled, just
   keep a reference to the string, don't copy characters
 * Avoid a call to the expensive _PyUnicode_FindMaxChar() function when
   possible
2013-04-03 01:48:39 +02:00
Ezio Melotti 33136fa6e7 #17217: merge with 3.3. 2013-02-23 07:58:28 +02:00
Ezio Melotti 4ad8eec09e #17217: merge with 3.2. 2013-02-23 07:57:53 +02:00
Ezio Melotti 507eb09ad6 #17217: fix UnicodeEncodeErrors errors in test_format by printing ASCII only. 2013-02-23 07:53:56 +02:00
Victor Stinner 621ef3d84f Issue #15609: Optimize str%args for integer argument
- Use _PyLong_FormatWriter() instead of formatlong() when possible, to avoid
   a temporary buffer
 - Enable the fast path when width is smaller or equals to the length,
   and when the precision is bigger or equals to the length
 - Add unit tests!
 - formatlong() uses PyUnicode_Resize() instead of _PyUnicode_FromASCII()
   to resize the output string
2012-10-02 00:33:47 +02:00
Victor Stinner 184252ad3f Fix "%f" format of str%args if the result is not an ASCII or latin1 string 2012-06-16 02:57:41 +02:00
Stefan Krah 0509d9418a Issue #14113: Fix a test_strptime failure caused by changes to LC_ALL. 2012-02-27 10:18:51 +01:00
Victor Stinner 90f50d4df9 Issue #13706: Fix format(float, "n") for locale with non-ASCII decimal point (e.g. ps_aF) 2012-02-24 01:44:47 +01:00
Victor Stinner 41a863cb81 Issue #13706: Fix format(int, "n") for locale with non-ASCII thousands separator
* Decode thousands separator and decimal point using PyUnicode_DecodeLocale()
   (from the locale encoding), instead of decoding them implicitly from latin1
 * Remove _PyUnicode_InsertThousandsGroupingLocale(), it was not used
 * Change _PyUnicode_InsertThousandsGrouping() API to return the maximum
   character if unicode is NULL
 * Replace MIN/MAX macros by Py_MIN/Py_MAX
 * stringlib/undef.h undefines STRINGLIB_IS_UNICODE
 * stringlib/localeutil.h only supports Unicode
2012-02-24 00:37:51 +01:00
Victor Stinner a4ac600d6f Issue #13706: Support non-ASCII fill characters 2012-01-21 15:50:49 +01:00
Mark Dickinson b7be5703fb Merged revisions 78372-78373 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r78372 | mark.dickinson | 2010-02-23 12:53:52 +0000 (Tue, 23 Feb 2010) | 1 line

  Make global variable overflowok into a keyword argument;  this fixes a failure when running ./python -m test.regrtest -R 3:2: test_format
........
  r78373 | mark.dickinson | 2010-02-23 13:06:50 +0000 (Tue, 23 Feb 2010) | 1 line

  Fix spacing nit.  Thanks Eric Smith for the public humiliation.
........
2010-02-23 13:20:58 +00:00
Mark Dickinson 5354a1fce0 Merged revisions 78082,78086 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r78082 | mark.dickinson | 2010-02-07 13:01:56 +0000 (Sun, 07 Feb 2010) | 1 line

  Add missing global declarations for 'overflowok'; remove 'overflowrequired', which is no longer needed.
........
  r78086 | mark.dickinson | 2010-02-07 13:09:52 +0000 (Sun, 07 Feb 2010) | 1 line

  Actually raise on failure, instead of doing nothing.
........
2010-02-07 13:15:37 +00:00
Eric Smith 0923d1d8d7 The other half of Issue #1580: use short float repr where possible.
Addresses the float -> string conversion, using David Gay's code which
was added in Mark Dickinson's checkin r71663.

Also addresses these, which are intertwined with the short repr
changes:

- Issue #5772: format(1e100, '<') produces '1e+100', not '1.0e+100'
- Issue #5515: 'n' formatting with commas no longer works poorly
    with leading zeros.
- PEP 378 Format Specifier for Thousands Separator: implemented
    for floats.
2009-04-16 20:16:10 +00:00
Amaury Forgeot d'Arc a083f1eb5f The Unicode database was updated to 5.1, and some characters have become printable.
Change the tests and use another code point.
2008-09-10 23:51:42 +00:00
Eric Smith 22b85b3ef8 Backed out r65073, pending fixing it in Windows. 2008-07-17 19:18:29 +00:00
Eric Smith a4fac36eb3 Merged revisions 65069 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r65069 | eric.smith | 2008-07-17 13:48:39 -0400 (Thu, 17 Jul 2008) | 1 line

  Issue 3382: Make '%F' and float.__format__('F') convert results to upper case.
........
2008-07-17 18:30:48 +00:00
Amaury Forgeot d'Arc a819caadef Correct a test after r64701. 2008-07-04 17:57:09 +00:00