[issue7330] PyUnicode_FromFormat: implement width and precision for %s, %S, %R, %V, %U, %A

2013-05-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 9e0f1c3bf9b6 by Victor Stinner in branch 'default':
Issue #7330: Implement width and precision (ex: %5.3s) for the format string
http://hg.python.org/cpython/rev/9e0f1c3bf9b6

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7330
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7330] PyUnicode_FromFormat: implement width and precision for %s, %S, %R, %V, %U, %A

2013-05-06 Thread STINNER Victor

STINNER Victor added the comment:

Finally, I closed this issue. Sorry for the long delay, but many other 
PyUnicode_FromFormat() issues had to be discussed/fixed before this one can be 
fixed. It was also much easier to fix this issue since my refactoring of 
PyUnicode_FromFormat() to only parse the format string once (thanks to the 
_PyUnicodeWriter API) instead of having 4 steps.

Thanks to Ysj Ray, thanks to reviewers.

This is one of the oldest issue that I had to fix :-)

--
resolution:  - fixed
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7330
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7330] PyUnicode_FromFormat: implement width and precision for %s, %S, %R, %V, %U, %A

2013-05-05 Thread STINNER Victor

STINNER Victor added the comment:

New version of my patch taking Serhiy's remarks into account:

 - add a check_format() function to cleanup unit tests
 - only call _PyUnicodeWriter_Prepare() once per formatted argument: compute 
the length and maximum character. Be more optimistic about sprintf() for 
integer and pointer: expect that the maximum character is 127 or less
 - uniformize code parsing width and precision
 - factorize code for '%s' and '%V'

Note: remove also _PyUnicode_WriteSubstring() from the patch, it was already 
added.

--
Added file: 
http://bugs.python.org/file30144/unicode_fromformat_precision-3.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7330
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7330] PyUnicode_FromFormat: implement width and precision for %s, %S, %R, %V, %U, %A

2013-05-05 Thread STINNER Victor

STINNER Victor added the comment:

I didn't add the following optimization (proposed by Serhiy in his review) 
because I'm not convinced that it's faster, and it's unrelated to this issue:

   if (width  (PY_SSIZE_T_MAX - 9) / 10
width  (PY_SSIZE_T_MAX - ((int)*f - '0')) / 10)
   { ... }

instead of 

   if (width  (PY_SSIZE_T_MAX - ((int)*f - '0')) / 10)
   { ... }

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7330
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7330] PyUnicode_FromFormat: implement width and precision for %s, %S, %R, %V, %U, %A

2013-01-27 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
type: crash - enhancement
versions: +Python 3.4 -Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7330
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7330] PyUnicode_FromFormat: implement width and precision for %s, %S, %R, %V, %U, %A

2012-12-09 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I found one bug and add some nitpicks and optimization suggestion on Rietveld.

--
nosy: +serhiy.storchaka

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7330
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7330] PyUnicode_FromFormat: implement width and precision for %s, %S, %R, %V, %U, %A

2012-12-08 Thread Sean Ochoa

Changes by Sean Ochoa sean.m.oc...@gmail.com:


--
nosy: +Sean.Ochoa

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7330
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7330] PyUnicode_FromFormat: implement width and precision for %s, %S, %R, %V, %U, %A

2012-10-07 Thread STINNER Victor

STINNER Victor added the comment:

Updated patch: precision for %s and %V (if the first PyObject* argument is 
NULL) formats is now a number of bytes, rather than a number of characters. 
width is still always a number of character.

The reason is that %.100s can be used for avoid a crash if the argument is 
not terminated by a null character (see issue #10833).

--
Added file: 
http://bugs.python.org/file27479/unicode_fromformat_precision-2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7330
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7330] PyUnicode_FromFormat: implement width and precision for %s, %S, %R, %V, %U, %A

2012-10-06 Thread STINNER Victor

STINNER Victor added the comment:

I rewrote PyUnicode_FromFormatV() to use a single step instead of four: see 
issue #16147. So it's now simpler to fix this issue. Here is a new patch to 
implement width and precision modifiers for %s, %A, %R, %S and %U formats.

--
Added file: http://bugs.python.org/file27465/unicode_fromformat_precision.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7330
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7330] PyUnicode_FromFormat: implement width and precision for %s, %S, %R, %V, %U, %A

2012-10-06 Thread STINNER Victor

STINNER Victor added the comment:

I read again this old issue. I still think that it would be better to truncate 
to a number of *bytes* for %s format (and %V format when the first argument 
is NULL) to mimic printf(). The replace error handler of the UTF-8 decoder 
handles truncated string correctly. So I should update my patch.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7330
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7330] PyUnicode_FromFormat: implement width and precision for %s, %S, %R, %V, %U, %A

2011-11-19 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Hi!

I'd like to have this committed to be able to fix #13349. So here's a review.

- In Doc/c-api/unicode.rst, the two versionchanged:: 3.3 directives can be 
merged

- In tests, I'd use 'abcde' rather than 'x' to make sure that correct 
characters are copied to the output (hope you understand what I mean)

- No test checks that width and precision work on characters rather than bytes

- The changes to unicodeobject.c don't apply on top of current default branch.

--
keywords: +needs review
stage:  - patch review
versions: +Python 3.3 -Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7330
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7330] PyUnicode_FromFormat: implement width and precision for %s, %S, %R, %V, %U, %A

2011-11-18 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

Issue #13428 has been marked as a duplicate of this issue.

--
nosy: +petri.lehtinen

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7330
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7330] PyUnicode_FromFormat: implement width and precision for %s, %S, %R, %V, %U, %A

2011-10-09 Thread lekma

Changes by lekma lekma...@gmail.com:


--
nosy: +lekma

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7330
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7330] PyUnicode_FromFormat: implement width and precision for %s, %S, %R, %V, %U, %A

2011-09-29 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

Hum, the issue is still open, I will try to review it.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7330
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7330] PyUnicode_FromFormat: implement width and precision for %s, %S, %R, %V, %U, %A

2011-03-24 Thread Ray.Allen

Ray.Allen ysj@gmail.com added the comment:

By the way, as my simple tests, wprintf() with %ls does apply the width and 
precision formatters on units of characters.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7330
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7330] PyUnicode_FromFormat: implement width and precision for %s, %S, %R, %V, %U, %A

2011-03-24 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

There are 4 patches issue 7030 attached to this issue. Some of them have a 
version number in their name, some doesn't. You did the same on other issues. 
It is more easy to follow a patch if it has a version number, for example: 
issue_7330.diff, issue_7330-2.diff, issue_7330-3.diff, issue_7330-4.diff, ... 
And I suppose that you can remove all old patches, except if they are 
alternative implementations or contain something special.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7330
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7330] PyUnicode_FromFormat: implement width and precision for %s, %S, %R, %V, %U, %A

2011-03-24 Thread Ray.Allen

Ray.Allen ysj@gmail.com added the comment:

Sorry for having done that! I will remove old patches and leave a cleaner view.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7330
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7330] PyUnicode_FromFormat: implement width and precision for %s, %S, %R, %V, %U, %A

2011-03-24 Thread Ray.Allen

Changes by Ray.Allen ysj@gmail.com:


Removed file: http://bugs.python.org/file20739/issue_7330.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7330
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7330] PyUnicode_FromFormat: implement width and precision for %s, %S, %R, %V, %U, %A

2011-03-24 Thread Ray.Allen

Changes by Ray.Allen ysj@gmail.com:


Removed file: http://bugs.python.org/file20786/issue_7330.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7330
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7330] PyUnicode_FromFormat: implement width and precision for %s, %S, %R, %V, %U, %A

2011-03-24 Thread Ray.Allen

Changes by Ray.Allen ysj@gmail.com:


Removed file: http://bugs.python.org/file20983/issue7330_2.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7330
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7330] PyUnicode_FromFormat: implement width and precision for %s, %S, %R, %V, %U, %A

2011-03-24 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

I closed #10833 as invalid, because it is a regression of Python 3. 
PyErr_String() uses PyString_FromFormatV() in Python 2, which supports 
precision for %s, whereas it uses PyUnicode_FromFormatV() in Python 3, which 
never supported precision for %s.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7330
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7330] PyUnicode_FromFormat: implement width and precision for %s, %S, %R, %V, %U, %A

2011-03-21 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

Ray Allen: Your patch doesn't touch the documentation. At least, you should 
mention (using .. versionchanged:: 3.3) that PyUnicode_FromFormat() does now 
support width and precision. It is important to specify the unit of the sizes: 
number of bytes or number of characters? Because many developer may refer to 
printf() which counts in bytes (especially for %s). PyUnicode_FromFormat() is 
more close to wprintf(), but I don't know if wprintf() uses bytes or characters 
for width and precision with the %s and %ls formats.

I plan to fix #10833 by replacing %.100s by %s is most (or all) error messages, 
and then commit your patch.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7330
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7330] PyUnicode_FromFormat: implement width and precision for %s, %S, %R, %V, %U, %A

2011-03-21 Thread Ray.Allen

Changes by Ray.Allen ysj@gmail.com:


Removed file: http://bugs.python.org/file21032/issue7330_3.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7330
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7330] PyUnicode_FromFormat: implement width and precision for %s, %S, %R, %V, %U, %A

2011-03-21 Thread Ray.Allen

Ray.Allen ysj@gmail.com added the comment:

Ooops! I found my last submitted patch is a wrong one.


Here is the updated patch add doc entries about the changes. The test cases 
which assert error messages generated by PyUnicode_FromFormat() with %.200s 
formatters equality would failed due to this patch. Hope you don't miss any of 
them.

--
Added file: http://bugs.python.org/file21324/issue_7330.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7330
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7330] PyUnicode_FromFormat: implement width and precision for %s, %S, %R, %V, %U, %A

2011-03-21 Thread Roundup Robot

Roundup Robot devnull@devnull added the comment:

New changeset d3ae3fe3eb97 by Victor Stinner in branch 'default':
Issue #7330, #10833: Replace %100s by %.100s and %200s by %.200s
http://hg.python.org/cpython/rev/d3ae3fe3eb97

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7330
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7330] PyUnicode_FromFormat: implement width and precision for %s, %S, %R, %V, %U, %A

2011-03-07 Thread Ray.Allen

Ray.Allen ysj@gmail.com added the comment:

I noticed that after apply my last patch and running full unittest cases, some 
weird errors which I don't know the reasons occurred, for example:

AttributeError: 'dict' object has no attribute 'get'
and
AttributeError: 'Queue' object has no attribute 'get'

I didn't look deep into it. But I found after I optimist my patch, these errors 
disappeared: I removed the unicode_format_align() function in previous patch, 
directly add needed spaces and copy part of unicode got from parameters 
according to width and precision formatters in step 4(using Py_UNICODE_FILL() 
and Py_UNICODE_COPY()) . This avoid create temporary unicode objects using 
unicode_format_align() in step 3. And also the patch becomes simpler.

So this patch is intended to replace of the previous. And if I have more time, 
I will try to find the reasons of the weird errors.

--
Added file: http://bugs.python.org/file21032/issue7330_3.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7330
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7330] PyUnicode_FromFormat: implement width and precision for %s, %S, %R, %V, %U, %A

2011-03-03 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@haypocalc.com:


--
title: PyUnicode_FromFormat segfault - PyUnicode_FromFormat: implement width 
and precision for %s, %S, %R, %V, %U, %A

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7330
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com