Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(22690)

Side by Side Diff: Python/formatter_unicode.c

Issue 8931: '#' has no affect with 'c' type
Patch Set: Created 7 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_types.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* implements the unicode (as opposed to string) version of the 1 /* implements the unicode (as opposed to string) version of the
2 built-in formatters for string, int, float. that is, the versions 2 built-in formatters for string, int, float. that is, the versions
3 of int.__float__, etc., that take and return unicode objects */ 3 of int.__float__, etc., that take and return unicode objects */
4 4
5 #include "Python.h" 5 #include "Python.h"
6 #include <locale.h> 6 #include <locale.h>
7 7
8 /* Raises an exception about an unknown presentation type for this 8 /* Raises an exception about an unknown presentation type for this
9 * type. */ 9 * type. */
10 10
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 "Precision not allowed in integer format specifier"); 782 "Precision not allowed in integer format specifier");
783 goto done; 783 goto done;
784 } 784 }
785 785
786 /* special case for character formatting */ 786 /* special case for character formatting */
787 if (format->type == 'c') { 787 if (format->type == 'c') {
788 /* error to specify a sign */ 788 /* error to specify a sign */
789 if (format->sign != '\0') { 789 if (format->sign != '\0') {
790 PyErr_SetString(PyExc_ValueError, 790 PyErr_SetString(PyExc_ValueError,
791 "Sign not allowed with integer" 791 "Sign not allowed with integer"
792 " format specifier 'c'");
793 goto done;
794 }
795 /* error to request alternate format */
796 if (format->alternate) {
797 PyErr_SetString(PyExc_ValueError,
798 "Alternate form (#) not allowed with integer"
792 " format specifier 'c'"); 799 " format specifier 'c'");
793 goto done; 800 goto done;
794 } 801 }
795 802
796 /* taken from unicodeobject.c formatchar() */ 803 /* taken from unicodeobject.c formatchar() */
797 /* Integer input truncated to a character */ 804 /* Integer input truncated to a character */
798 /* XXX: won't work for int */ 805 /* XXX: won't work for int */
799 x = PyLong_AsLong(value); 806 x = PyLong_AsLong(value);
800 if (x == -1 && PyErr_Occurred()) 807 if (x == -1 && PyErr_Occurred())
801 goto done; 808 goto done;
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
1464 1471
1465 default: 1472 default:
1466 /* unknown */ 1473 /* unknown */
1467 unknown_presentation_type(format.type, obj->ob_type->tp_name); 1474 unknown_presentation_type(format.type, obj->ob_type->tp_name);
1468 goto done; 1475 goto done;
1469 } 1476 }
1470 1477
1471 done: 1478 done:
1472 return result; 1479 return result;
1473 } 1480 }
OLDNEW
« no previous file with comments | « Lib/test/test_types.py ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+