[issue24567] random.choice IndexError due to double-rounding

2015-07-11 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Unfortunately a link to Rietveld is not available for review and inlined comments. In sample() the selected set can be initialized to {n} to avoid additional checks in the loop for large population. In the branch for small population, non-empty pool can be

[issue24567] random.choice IndexError due to double-rounding

2015-07-11 Thread Raymond Hettinger
Changes by Raymond Hettinger : Added file: http://bugs.python.org/file39905/handle_double_rounding2.diff ___ Python tracker ___ ___ Python-bug

[issue24567] random.choice IndexError due to double-rounding

2015-07-11 Thread Raymond Hettinger
Changes by Raymond Hettinger : Removed file: http://bugs.python.org/file39903/handle_double_rounding.diff ___ Python tracker ___ ___ Python-bu

[issue24379] operator.subscript

2015-07-11 Thread Joe Jevnik
Joe Jevnik added the comment: updating to address the docs and order of assertions -- Added file: http://bugs.python.org/file39904/operator_subscript_pyonly.patch ___ Python tracker

[issue24567] random.choice IndexError due to double-rounding

2015-07-11 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- keywords: +patch Added file: http://bugs.python.org/file39903/handle_double_rounding.diff ___ Python tracker ___ ___

[issue24379] operator.subscript

2015-07-11 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: The implementation itself LGTM (nice use of decorator). New feature should be documented. Needed changes in Doc/library/operator.rst and Doc/whatsnew/3.6.rst and the docstring for the subscript class. 'subscript' should be added to __all__. --

[issue23220] Documents input/output effects of how IDLE runs user code

2015-07-11 Thread Martin Panter
Martin Panter added the comment: I wouldn’t say TK ignores carriage returns, though I agree it would be better if Idle stripped them out. Currently I get a glyph displayed for them, similarly to \b. They wouldn’t copy to my clipboard, so I fudged them after pasting here: >>> _ = stdout.write(

[issue24587] Tkinter stacking versus focus behavior on Windows

2015-07-11 Thread Eugene K.
Eugene K. added the comment: It may not be a pure Python bug, but it's definitely at least a tk bug (which makes it a Python bug as long as tk is the canonical UI package in Python.) Workarounds are nice, but a workaround fixes my specific problem here and now, while leaving unknown numbers o

[issue24567] random.choice IndexError due to double-rounding

2015-07-11 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: For shuffle I would write "if j < i". I think 3.x should be fixed as well as 2.7. And I like Tim's suggestion about import-time patching. -- ___ Python tracker

[issue24379] operator.subscript

2015-07-11 Thread Joe Jevnik
Joe Jevnik added the comment: updating with the slots change This also adds a ton of test cases -- Added file: http://bugs.python.org/file39902/operator_subscript_pyonly.patch ___ Python tracker __

[issue23220] Documents input/output effects of how IDLE runs user code

2015-07-11 Thread Terry J. Reedy
Terry J. Reedy added the comment: I was thinking AttributeError, as mentioned in the previous sentence. But you are correct that ImportError is possible too. Maybe I should just give the code. try: import idlelib idlelib.run running_idle = True except (ImportError, AttributeError

[issue24567] random.choice IndexError due to double-rounding

2015-07-11 Thread Raymond Hettinger
Raymond Hettinger added the comment: See the attached timings. The performance hit isn't bad and the code's beauty isn't marred terribly. Yes, we'll fix it, but no I don't have to feel good about it ;-) -- ___ Python tracker

[issue24613] array.fromstring Use After Free

2015-07-11 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- assignee: -> serhiy.storchaka components: +Extension Modules nosy: +serhiy.storchaka stage: -> patch review ___ Python tracker ___

[issue24587] Tkinter stacking versus focus behavior on Windows

2015-07-11 Thread Terry J. Reedy
Terry J. Reedy added the comment: The issue is the interaction between stacking and focus. I am pretty sure that this is not a Python bug and that this issue should be closed. I suspect that the behavior is not even a tk bug, but simply how Windows' graphics system work. In any case, the atta

[issue23220] Documents input/output effects of how IDLE runs user code

2015-07-11 Thread Martin Panter
Martin Panter added the comment: “run ``import idlelib; idlelib.run`` within a try-except statement”: It might be nice to say what exceptions are expected. My guess is ImportError if Idle or TK is not available, or AttributeError if it is but Idle is not running. “Tk handling of ascii control

[issue24379] operator.subscript

2015-07-11 Thread Joe Jevnik
Joe Jevnik added the comment: Ah, I hadn't seen that, I will address those now, sorry about that. -- ___ Python tracker ___ ___ Python

[issue24379] operator.subscript

2015-07-11 Thread Martin Panter
Martin Panter added the comment: Joe: Have you seen the comments on the code review? See the Review link at the top of the bug thread, or maybe check your spam. -- nosy: +vadmium stage: -> patch review ___ Python tracker

[issue24567] random.choice IndexError due to double-rounding

2015-07-11 Thread Tim Peters
Tim Peters added the comment: [Raymond] > I can't say that I feel good about making everyone pay > a price for a problem that almost no one ever has. As far as I know, nobody has ever had the problem. But if we know a bug exists, I think it's at best highly dubious to wait for a poor user to g

[issue24613] array.fromstring Use After Free

2015-07-11 Thread John Leitch
John Leitch added the comment: Attaching patch. -- keywords: +patch Added file: http://bugs.python.org/file39900/arraymodule.c.patch ___ Python tracker ___ __

[issue24613] array.fromstring Use After Free

2015-07-11 Thread John Leitch
New submission from John Leitch: The Python array.fromstring() method suffers from a use after free caused by unsafe realloc use. The issue is triggered when an array is concatenated to itself via fromstring() call: static PyObject * array_fromstring(arrayobject *self, PyObject *args) { ch

[issue24612] not operator expression raising a syntax error

2015-07-11 Thread Martin Panter
Martin Panter added the comment: BTW “yield” is not a fair comparison because its syntax is even stranger (due to originally being a “yield” statement): def g(): x = yield + 1 # Yield the value +1 y = (yield) + 1 # Add 1 after yielding return (yield) # Mandatory brackets ---

[issue24612] not operator expression raising a syntax error

2015-07-11 Thread Martin Panter
Martin Panter added the comment: Funny, I ran into this one or two days ago, when refactoring some code that used the bitwise exclusive-or operator, since there is no boolean exclusive or: -if (x == a) ^ (y != b): ... +aa = x == a +bb = y == b +if aa ^ not bb: ... It is fairly clear what I wan

[issue24567] random.choice IndexError due to double-rounding

2015-07-11 Thread Raymond Hettinger
Changes by Raymond Hettinger : Added file: http://bugs.python.org/file39898/shuffle_timings.txt ___ Python tracker ___ ___ Python-bugs-list ma

[issue24379] operator.subscript

2015-07-11 Thread Joe Jevnik
Joe Jevnik added the comment: ping: is there anything blocking this? -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsub

[issue24567] random.choice IndexError due to double-rounding

2015-07-11 Thread Raymond Hettinger
Changes by Raymond Hettinger : Added file: http://bugs.python.org/file39897/choice_timings.txt ___ Python tracker ___ ___ Python-bugs-list mai

[issue24610] Incorrect example Unicode string in docs footnote

2015-07-11 Thread Roundup Robot
Roundup Robot added the comment: New changeset 1cae77f873af by Benjamin Peterson in branch '3.4': fix normalization example (closes #24610) https://hg.python.org/cpython/rev/1cae77f873af New changeset 0127b0cad5ec by Benjamin Peterson in branch '3.5': merge 3.4 (#24610) https://hg.python.org/cpy

[issue24567] random.choice IndexError due to double-rounding

2015-07-11 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- assignee: -> rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http

[issue24567] random.choice IndexError due to double-rounding

2015-07-11 Thread Raymond Hettinger
Raymond Hettinger added the comment: FWIW, here are some variants (with differing degrees of brevity, clarity, and performance): def choice(self, seq): """Choose a random element from a non-empty sequence.""" n = len(seq) i = int(self.random() * n) if i == n:

[issue24567] random.choice IndexError due to double-rounding

2015-07-11 Thread Raymond Hettinger
Raymond Hettinger added the comment: [Antoine] > If that would give a different sequence of random numbers, > I'm not sure that's acceptable in a bugfix release. Raymond > can shed a light. You're right. It is not acceptable to give a different sequence of random numbers within a bugfix relea

[issue23220] Documents input/output effects of how IDLE runs user code

2015-07-11 Thread Terry J. Reedy
Terry J. Reedy added the comment: Serhiy, thanks for the paraphrase of what I tried to say. This issue has already been changed to a doc issue to explain the input/output effects of Idle's way of running user code. I should have retitled before. Control codes are just one of the effects tha

[issue24612] not operator expression raising a syntax error

2015-07-11 Thread Martin Panter
Changes by Martin Panter : -- nosy: +vadmium ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pytho

[issue24612] not operator expression raising a syntax error

2015-07-11 Thread Stefan Behnel
Stefan Behnel added the comment: Hmm, right. I see your point and also the analogy with "yield". I could live with (maybe) giving it a better error message suggesting to use parentheses for clarity and otherwise keeping it a SyntaxError. -- ___ Pyth

[issue24612] not operator expression raising a syntax error

2015-07-11 Thread Matthew Barnett
Matthew Barnett added the comment: "not" has a lower priority than unary "-"; this: not a < b is parsed as: not (a < b) How would you parse: 0 + not 0 + 0 ? Would it be parsed as: 0 + not (0 + 0) ? Similar remarks could apply to "yield": 0 + yield 0 which is also a

[issue19713] Deprecate various things in importlib thanks to PEP 451

2015-07-11 Thread Petr Viktorin
Changes by Petr Viktorin : -- nosy: +encukou ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pytho

[issue24612] not operator expression raising a syntax error

2015-07-11 Thread Stefan Behnel
Stefan Behnel added the comment: It looks like perfectly valid syntax to me and I cannot see why it should be semantically rejected. I disagree that it shouldn't be changed. I think it's a (minor) bug that should eventually get fixed. -- nosy: +scoder _

[issue24611] Compiling Python 2.7.10 Error on Unixware 7.1.4

2015-07-11 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I think this simple patch should fix the issue. -- keywords: +patch stage: needs patch -> patch review Added file: http://bugs.python.org/file39896/issue24611.patch ___ Python tracker

[issue24587] Incorrect tkinter behavior of slave widgets of Button

2015-07-11 Thread Eugene K.
Eugene K. added the comment: File attached -- Added file: http://bugs.python.org/file39895/bug.py ___ Python tracker ___ ___ Python-bu

[issue24612] not operator expression raising a syntax error

2015-07-11 Thread Steven D'Aprano
Steven D'Aprano added the comment: On Sat, Jul 11, 2015 at 03:23:53PM +, candide wrote: > > New submission from candide: > > Expressions such as > > a + not b > a * not b > + not b > - not b > > raise a SyntaxError, for instance : > > > >>> 0 + not 0 > File "", line 1 > 0 + not 0

[issue24612] not operator expression raising a syntax error

2015-07-11 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: "not not 0" is compiled successful, while "+ not 0", "- not 0", and "~ not 0" are rejected. -- nosy: +benjamin.peterson ___ Python tracker __

[issue24612] not operator expression raising a syntax error

2015-07-11 Thread candide
New submission from candide: Expressions such as a + not b a * not b + not b - not b raise a SyntaxError, for instance : >>> 0 + not 0 File "", line 1 0 + not 0 ^ SyntaxError: invalid syntax >>> - not 0 File "", line 1 - not 0 ^ SyntaxError: invalid syntax >>> i

[issue24611] Compiling Python 2.7.10 Error on Unixware 7.1.4

2015-07-11 Thread R. David Murray
R. David Murray added the comment: unixware is not a platform we support (we don't have a buildbot for it). If you can figure out how to fix this and it isn't disruptive to the codebase, you can submit a patch. -- nosy: +r.david.murray ___ Python t

[issue24611] Compiling Python 2.7.10 Error on Unixware 7.1.4

2015-07-11 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- assignee: -> serhiy.storchaka nosy: +serhiy.storchaka stage: -> needs patch ___ Python tracker ___

[issue24611] Compiling Python 2.7.10 Error on Unixware 7.1.4

2015-07-11 Thread Ron Barak
New submission from Ron Barak: I wanted to add Python 2.7 to Unix. I downloaded the sources to the VirtualBox on which the Unix is installed and run ./configure --prefix=/usr \ --enable-shared \ --with-system-expat \ without problems. However, when I try to r

[issue23601] use small object allocator for dict key storage

2015-07-11 Thread Julian Taylor
Julian Taylor added the comment: ok I ran it again, but note the machine was under use the full time so the results are likely have no meaning. python perf.py -r -b default /tmp/normal/bin/python3 /tmp/opt/bin/python3 Min: 0.399279 -> 0.376527: 1.06x faster Avg: 0.410819 -> 0.383315: 1.07x fas

[issue23220] IDLE does not display \b backspace correctly.

2015-07-11 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Control characters are named control characters because they are control the output device. Different devices have different capabilities and reacts different on the same codes. Windows console, different sorts of Linux terminals and Tk text widget are diffe

[issue24610] Incorrect example Unicode string in docs footnote

2015-07-11 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: LGTM. The 2.x docs were fixed in c9bf6e70308e, but this change was lost during merging to 3.x in 3d866579117d. -- components: +Unicode nosy: +ezio.melotti, haypo, serhiy.storchaka stage: -> commit review versions: +Python 3.4, Python 3.5 __

[issue24610] Incorrect example Unicode string in docs footnote

2015-07-11 Thread Chris Angelico
Chris Angelico added the comment: Interestingly, the 2.7 docs have this correct already. https://docs.python.org/2.7/reference/expressions.html#id23 -- ___ Python tracker ___ __

[issue24610] Incorrect example Unicode string in docs footnote

2015-07-11 Thread Chris Angelico
New submission from Chris Angelico: https://docs.python.org/3/reference/expressions.html#id18 The string "\u0327\u0043" does not normalize to the same string as "\u00C7", as combining characters are supposed to _follow_ the base character. (Some consoles may happen to display them the same way

[issue24595] InteractiveInterpreter always prints to stdout

2015-07-11 Thread Terry J. Reedy
Terry J. Reedy added the comment: To me, this cries out for a public context manager ( believe there is a public one in test.support, or something), so one can write with stdout(ob): print(stuff) I am not sure, though, where the C.M.s should live. -- nosy: +terry.reedy

[issue24587] Incorrect tkinter behavior of slave widgets of Button

2015-07-11 Thread Terry J. Reedy
Terry J. Reedy added the comment: Please attach the file to this issue, using the [Browse] button. -- nosy: +serhiy.storchaka, terry.reedy ___ Python tracker ___

[issue23220] IDLE does not display \b backspace correctly.

2015-07-11 Thread Terry J. Reedy
Terry J. Reedy added the comment: I closed #24572 as a duplicate of this. It is the same issue except for printing \r instead of \b. These issues are not about responses to keyboard actions when entering text into an Idle editor window. During entry, just about any cntl/alt/function/shift/ke