[issue7330] PyUnicode_FromFormat segfault

2011-03-03 Thread Ray.Allen
Ray.Allen added the comment: Here is the updated patch: 1, Work with function parse_format_flags() which is introduced in issue10829, and the patch is simpler and more clear than before. 2, Change parse_format_flags() to set precision value to -1 in the case of '%s' in order to differ with '%

[issue7330] PyUnicode_FromFormat segfault

2011-02-20 Thread Ray.Allen
Changes by Ray.Allen : Removed file: http://bugs.python.org/file20739/issue_7330.diff ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue7330] PyUnicode_FromFormat segfault

2011-02-20 Thread Ray.Allen
Ray.Allen added the comment: > > > With your patch, "%.200s" truncates the input string to 200 *characters*, > > > but I think that it should truncate to 200 *bytes*, as printf does. > > > > Sorry, I don't understand. The result of PyUnicode_FromFormatV() is a > > unicode object. Then how to

[issue7330] PyUnicode_FromFormat segfault

2011-02-18 Thread Ray.Allen
Ray.Allen added the comment: > Can you add tests for "%.s"? I would like to know if "%.s" is different than > "%s" :-) Oh sorry~~ I made an mistake. There is no bug here. I have attached tests that show that '%.s' is the same as '%s'. Here is the updated patch: 1, changed the function name

[issue7330] PyUnicode_FromFormat segfault

2011-02-18 Thread STINNER Victor
STINNER Victor added the comment: > Oh, what if the trunked char* cannot be decoded correctly? > e.g. a tow-bytes character is divided in the middle? Yes, but PyUnicode_FromFormatV() uses UTF-8 decoder with replace error handler, and so the incomplete byte sequence will be replaced by � (it d

[issue7330] PyUnicode_FromFormat segfault

2011-02-18 Thread Ray.Allen
Ray.Allen added the comment: > No you don't. You can copy a substring of the input string with Py_UNICODE_COPY: just pass a smaller length. Oh, yes, I got your meaning now. I'll follow this. > You can truncate the input char* on the call to PyUnicode_DecodeUTF8: Oh, what if the trunked char*

[issue7330] PyUnicode_FromFormat segfault

2011-02-17 Thread STINNER Victor
STINNER Victor added the comment: > > It looks like your patch fixes #10829: you should add tests for that, you > > can just reuse the tests of my patch (attached to #10829). > > Sorry, but I think my patch doesn't fix #10829. Ah ok, so don't add failing tests :-) > > You should also avoid t

[issue7330] PyUnicode_FromFormat segfault

2011-02-17 Thread Ray.Allen
Ray.Allen added the comment: > Do you mean combine step 3 and step 4 together? Currently step 3 is just to > compute the biggest width value and step 4 is to compute exact width and do > the real format work. Only by doing real format we can get the exact width of > a string. So I have to com

[issue7330] PyUnicode_FromFormat segfault

2011-02-17 Thread Ray.Allen
Ray.Allen added the comment: Thanks hyapo! > It looks like your patch fixes #10829: you should add tests for that, you can > just reuse the tests of my patch (attached to #10829). Sorry, but I think my patch doesn't fix #10829. It seems link another issue. And by applying my patch and add t

[issue7330] PyUnicode_FromFormat segfault

2011-02-13 Thread Ray.Allen
Changes by Ray.Allen : Removed file: http://bugs.python.org/file20731/issue_7330.diff ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue7330] PyUnicode_FromFormat segfault

2011-02-13 Thread Ray.Allen
Changes by Ray.Allen : Removed file: http://bugs.python.org/file19132/issue_7330.diff ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue7330] PyUnicode_FromFormat segfault

2011-02-13 Thread Ray.Allen
Changes by Ray.Allen : Removed file: http://bugs.python.org/file18305/issue_7330.diff ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue7330] PyUnicode_FromFormat segfault

2011-02-11 Thread STINNER Victor
STINNER Victor added the comment: It looks like your patch fixes #10829: you should add tests for that, you can just reuse the tests of my patch (attached to #10829). --- unicode_format() looks suboptimal. +memset(buffer, ' ', width); +width_unicode = PyUnicode_FromStringAndSize(buff

[issue7330] PyUnicode_FromFormat segfault

2011-02-10 Thread Ray.Allen
Ray.Allen added the comment: Here's the complete patch, added unittest for width modifier and precision modifier for '%s' formatter of PyUnicode_FromFormat() function. -- Added file: http://bugs.python.org/file20739/issue_7330.diff ___ Python tracke

[issue7330] PyUnicode_FromFormat segfault

2011-02-10 Thread Ray.Allen
Ray.Allen added the comment: Thanks haypo! Here is the updated patch, it add the tests about width modifiers and precision modifiers of %S, %R, %A. Besides I don't know how to add tests of %s, since when calling through ctypes, I could not get correct result value as python object from PyUni

[issue7330] PyUnicode_FromFormat segfault

2011-02-10 Thread Ray.Allen
Changes by Ray.Allen : Removed file: http://bugs.python.org/file19131/issue_7330.diff ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue7330] PyUnicode_FromFormat segfault

2011-02-01 Thread STINNER Victor
STINNER Victor added the comment: I opened other tickets related to PyUnicode_FromFormatV: * #10833 :Replace %.100s by %s in PyErr_Format(): the arbitrary limit of 500 bytes is outdated * #10831: PyUnicode_FromFormatV() doesn't support %li, %lli, %zi * #10830: PyUnicode_FromFormatV("%c") do

[issue7330] PyUnicode_FromFormat segfault

2011-01-31 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- components: +Unicode nosy: +haypo ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubsc

[issue7330] PyUnicode_FromFormat segfault

2010-10-05 Thread Ray.Allen
Ray.Allen added the comment: Oooops! Sorry for re-submit the request... -- ___ Python tracker ___ ___ Python-bugs-list mailing list Un

[issue7330] PyUnicode_FromFormat segfault

2010-10-05 Thread Ray.Allen
Ray.Allen added the comment: I update the patch. Hope somebody could do a review. -- Added file: http://bugs.python.org/file19132/issue_7330.diff ___ Python tracker ___ _

[issue7330] PyUnicode_FromFormat segfault

2010-10-05 Thread Ray.Allen
Ray.Allen added the comment: I update the patch. Hope somebody could do a review. -- Added file: http://bugs.python.org/file19131/issue_7330.diff ___ Python tracker ___ _

[issue7330] PyUnicode_FromFormat segfault

2010-08-01 Thread Ray.Allen
Ray.Allen added the comment: Here is the patch, it add support to use width and precision formatters in PyUnicode_FromFormat() for type %s, %S, %R, %V, %U, %A, besides fixed two bugs, which at least I believe: 1. According to PyUnicode_FromFormat() doc: http://docs.python.org/dev/py3k/c-api

[issue7330] PyUnicode_FromFormat segfault

2010-07-29 Thread Ray.Allen
Ray.Allen added the comment: Is this really worthy to fix? -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: h

[issue7330] PyUnicode_FromFormat segfault

2010-07-28 Thread Ray.Allen
Ray.Allen added the comment: You can write "%20s" as a argument for PyUnicode_FromFormat(), but it has no effect. The width and precision modifiers are not intended to apply to string formating(%s, %S, %R, %A), only apply to integer(%d, %u, %i, %x). Though you can write "%20s", but you canno

[issue7330] PyUnicode_FromFormat segfault

2010-07-28 Thread Eric Smith
Eric Smith added the comment: I think under the "we're all consenting adults" doctrine that it should be allowed. If you really want that behavior, why force the char*/%s dance at each call site when it's easy enough to do it in one place? I don't think anyone supplying a width would really b

[issue7330] PyUnicode_FromFormat segfault

2010-07-28 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Ray.Allen wrote: > > Ray.Allen added the comment: > > I feel it's not proper to allow the width restrict on types %S, %R, %A. These > types correspond to PyObject_Str(), PyObject_Repr, PyObject_ASCII() > respectively, the results of them are usually a c

[issue7330] PyUnicode_FromFormat segfault

2010-07-28 Thread Ray.Allen
Ray.Allen added the comment: I feel it's not proper to allow the width restrict on types %S, %R, %A. These types correspond to PyObject_Str(), PyObject_Repr, PyObject_ASCII() respectively, the results of them are usually a complete string representation of a object. If you put a width restric

[issue7330] PyUnicode_FromFormat segfault

2010-07-27 Thread Ezio Melotti
Changes by Ezio Melotti : -- nosy: +ezio.melotti ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.pyt

[issue7330] PyUnicode_FromFormat segfault

2010-07-27 Thread Ron Adam
Changes by Ron Adam : -- nosy: +ron_adam title: PyUnicode_FromFormat segfault when using widths. -> PyUnicode_FromFormat segfault ___ Python tracker ___ _

[issue7330] PyUnicode_FromFormat segfault when using widths.

2009-11-15 Thread Eric Smith
Eric Smith added the comment: It looks like PyUnicode_FromFormatV is computing callcount incorrectly. It's looking for 'S', 'R', or 'A' immediately following '%', before the width. It seems to me it should be treating them the same as 's', although I'll admit to not having looked at it close eno

[issue7330] PyUnicode_FromFormat segfault when using widths.

2009-11-15 Thread Mark Dickinson
New submission from Mark Dickinson : There seems to be something wrong with the width handling code in PyUnicode_FromFormat; or perhaps I'm misusing it. To reproduce: replace the line return PyUnicode_FromFormat("range(%R, %R)", r->start, r->stop); in range_repr in Objects/rangeobject.c