[issue29190] Avoid possible errors in comparing strings

2017-01-09 Thread Stefan Krah
Stefan Krah added the comment: On Mon, Jan 09, 2017 at 08:21:17AM +, Serhiy Storchaka wrote: > In the particular case of getround() in _decimal.c, seems the worst case is > raising TypeError instead of MemoryError in pretty rare circumstances. This > is not critically bad, there are a lot

[issue29190] Avoid possible errors in comparing strings

2017-01-09 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: In the particular case of getround() in _decimal.c, seems the worst case is raising TypeError instead of MemoryError in pretty rare circumstances. This is not critically bad, there are a lot of other places where the initial exception is silently replaced

[issue29190] Avoid possible errors in comparing strings

2017-01-09 Thread Roundup Robot
Roundup Robot added the comment: New changeset 337461574c90 by Serhiy Storchaka in branch '3.5': Issue #29190: Fixed possible errors in comparing strings in the pickle module. https://hg.python.org/cpython/rev/337461574c90 New changeset 9fcff936f61f by Serhiy Storchaka in branch '3.6': Issue

[issue29190] Avoid possible errors in comparing strings

2017-01-07 Thread Stefan Krah
Stefan Krah added the comment: I'm generally a little concerned about the way "bugs" are presented here recently: In #28701 you write: 'Correctness. Since no caller checks the error of PyUnicode_CompareWithASCIIString(), it is incorrectly interpreted as "less then".' This is just not true.

[issue29190] Avoid possible errors in comparing strings

2017-01-07 Thread Stefan Krah
Stefan Krah added the comment: To expand a little, you use the terminology "possible bugs". All I can see is a double exception if PyUnicode_Compare() returns -1. I think I did it on purpose because this function is speed sensitive and no user will change a valid rounding mode *constant* to a

[issue29190] Avoid possible errors in comparing strings

2017-01-07 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: In worst case ignoring an error can cause a mystical error later during executing an unrelated code or a crash in debug build. In both cases it is hard to find the location of the bug. -- nosy: +haypo ___ Python

[issue29190] Avoid possible errors in comparing strings

2017-01-07 Thread Stefan Krah
Stefan Krah added the comment: Also, if anyone changes the rounding-mode constants it is really their problem. -- ___ Python tracker ___

[issue29190] Avoid possible errors in comparing strings

2017-01-07 Thread Stefan Krah
Stefan Krah added the comment: Quite honestly I prefer to do nothing. What is the worst that can happen? A SystemError? Not-ready unicode strings are an application bug. -- ___ Python tracker

[issue29190] Avoid possible errors in comparing strings

2017-01-07 Thread Xiang Zhang
Xiang Zhang added the comment: Paste my point here: I prefer checking the result PyUnicode_Compare to see it's a success or failure. getrandom doesn't use any lower level unicode operations so it doesn't get a responsibility to ready the unicode. -- nosy: +xiang.zhang

[issue29190] Avoid possible errors in comparing strings

2017-01-07 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: An alternative patch checks the result of PyUnicode_Compare() (as Xiang suggested) instead of checking the value before calling PyUnicode_Compare(). Stephan, what way do you prefer? -- nosy: +facundobatista, mark.dickinson, rhettinger, skrah Added

[issue29190] Avoid possible errors in comparing strings

2017-01-06 Thread Serhiy Storchaka
New submission from Serhiy Storchaka: PyUnicode_Compare() and PyUnicode_RichCompare() can raise an exception if one of arguments is not ready unicode object. The result is not always checked for error. Proposed patch gets rid of possible bugs. PyUnicode_Compare() and PyUnicode_RichCompare()