[issue18875] Idle: Auto insertion of the closing parens, brackets, and braces

2018-04-05 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

My question about the idea is whether beginners would use this, or if it is the 
sort of 'expert' feature that IDLE should avoid.  I may ask on python-list for 
more opinions.

https://stackoverflow.com/questions/49677886/python-idle-symbol-completion/49684824#49684824
 adds a vote in favor.  It also prompted me to review the patch.

Since I said, 4 years ago, that the feature should be an extension, we have 
converted extensions to features.  So the patch needs re-writing, as I outlined.

(Although there is now an extension configuration dialog, it is no longer a 
dependency of this issue.)

I am not convinced that we need 5 configuration options, especially since I do 
not understand 2 of them ;-).  Do symbol and quote fences need to be separately 
enabled?  Does anyone known what other IDEs do?

--
dependencies:  -IDLE - Add an extension configuration dialog
versions: +Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33211] lineno and col_offset are wrong on function definitions with decorators

2018-04-05 Thread Ethan Smith

Ethan Smith  added the comment:

I have a branch with an implementation of my suggestion here: 
https://github.com/ethanhs/cpython/tree/decorlineno

I was hoping to see if this was seen as a reasonable patch that might be 
accepted.


Also, while I think it would be nice, I take it a patch for this would be 
unlikely to be backported, right?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33232] Segmentation fault in operator.attrgetter

2018-04-05 Thread Raymond Hettinger

Change by Raymond Hettinger :


--
assignee:  -> larry

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24882] ThreadPoolExecutor doesn't reuse threads until #threads == max_workers

2018-04-05 Thread iunknwn

iunknwn  added the comment:

I've submitted a PR that should resolve this - it uses a simple atomic counter 
to ensure new threads are not created if existing threads are idle. 

One concern I do have - while writing the patch, I noticed the existing submit 
method (specifically the adjust_thread_count function) isn't thread safe. I've 
added more details in the PR.

--
components: +Library (Lib)

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24882] ThreadPoolExecutor doesn't reuse threads until #threads == max_workers

2018-04-05 Thread iunknwn

Change by iunknwn :


--
nosy: +iunknwn

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33234] Improve list() pre-sizing for inputs with known lengths

2018-04-05 Thread Raymond Hettinger

New submission from Raymond Hettinger :

The list() constructor isn't taking full advantage of known input lengths or 
length hints.  Ideally, it should pre-size and not over-allocate when the input 
size is known or can be reasonably estimated.

Python 3.8.0a0 (heads/master:091e95e900, Apr  5 2018, 09:48:33)
[Clang 9.1.0 (clang-902.0.39.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from sys import getsizeof
>>> getsizeof([0] * 10)
144
>>> getsizeof(list([0] * 10))
200
>>> getsizeof(list(range(10)))
200

--
components: Interpreter Core
messages: 315006
nosy: rhettinger
priority: normal
severity: normal
status: open
title: Improve list() pre-sizing for inputs with known lengths
type: performance
versions: Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33232] Segmentation fault in operator.attrgetter

2018-04-05 Thread Ray Donnelly

Change by Ray Donnelly :


--
nosy: +Ray Donnelly

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33217] x in enum.Flag member is True when x is not a Flag

2018-04-05 Thread Ethan Furman

Change by Ethan Furman :


--
keywords: +patch
pull_requests: +6100
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27805] io.open('/dev/stdout', 'a') raises OSError with errno=ESPIPE

2018-04-05 Thread Skip Montanaro

Skip Montanaro  added the comment:

I was bitten by this porting a system from Python 2.7 to 3.6. "/dev/stderr" is 
a very nice default for logfiles. Users will frequently override the default, 
so you really want to open the logfile in append mode. Having to jump through 
hoops to avoid blasting a user's logfile is kinda dumb, and as others have 
pointed out, error-prone.

os.open works just fine with O_WRONLY|O_APPEND as the flags. /dev/null can be 
opened in append mode, but not /dev/stderr or /dev/stdout.

--
nosy: +skip.montanaro

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33224] "RuntimeError: generator raised StopIteration" in difflib.mdiff

2018-04-05 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

Thanks for timely report.  I appreciate you exercising the beta release to 
shake out bugs.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33224] "RuntimeError: generator raised StopIteration" in difflib.mdiff

2018-04-05 Thread Raymond Hettinger

Raymond Hettinger  added the comment:


New changeset 8da15f09458fd4f4fe341861e41723892b25a11b by Raymond Hettinger 
(Miss Islington (bot)) in branch '3.6':
bpo-33224: PEP 479 fix for difflib.mdiff() (GH-6381) (GH-6391)
https://github.com/python/cpython/commit/8da15f09458fd4f4fe341861e41723892b25a11b


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33233] Suggest third-party cmd2 module as alternative to cmd

2018-04-05 Thread Ned Deily

New submission from Ned Deily :

The cmd module in the standard library has languished for many years.  In the 
mean time, third-party replacements for it have arisen.  Perhaps the most 
popular is cmd2 which seems to be actively maintained, provides upward 
compatibility from cmd along with many desirable new features, and is 
permissively licensed.

I suggest we consider at a minimum adding a "See also:" note referencing cmd2 
to the cmd documentation in the Standard Library document, similar to what we 
do for the third-party "requests" module in the "urllib.request" documentation.

We could be even bolder and officially deprecate "cmd" and consider closing 
open enhancement issues for it on b.p.o.




https://pypi.org/project/cmd2/
https://cmd2.readthedocs.io/

--
assignee: docs@python
components: Documentation
messages: 315002
nosy: Catherine.Devlin, docs@python, lukasz.langa, ned.deily
priority: normal
severity: normal
status: open
title: Suggest third-party cmd2 module as alternative to cmd
versions: Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33224] "RuntimeError: generator raised StopIteration" in difflib.mdiff

2018-04-05 Thread Raymond Hettinger

Raymond Hettinger  added the comment:


New changeset 28c179094bcb7829d184fb3cfb3ef626505b9f77 by Raymond Hettinger 
(Miss Islington (bot)) in branch '3.7':
bpo-33224: PEP 479 fix for difflib.mdiff() (GH-6381) (GH-6390)
https://github.com/python/cpython/commit/28c179094bcb7829d184fb3cfb3ef626505b9f77


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33227] Cmd do_something only accepts one argument

2018-04-05 Thread Ned Deily

Ned Deily  added the comment:

Thanks for your suggested enhancement to the cmd module.  cmd has been around a 
*long* time and, unfortunately, has received very little maintenance or 
enhancement attention for many years.  In the meantime, third-party 
replacements for cmd have arisen.  One of the most popular is cmd2, available 
from PyPI, which has also been around a long time and appears to be actively 
maintained.  In particular, it looks like cmd2 already offers robust parsing of 
arguments.  While enhancing the standard library cmd module sounds like it 
might be a good idea, in this particular case, you and other potential users of 
cmd might be better off using cmd2.  In any case, unless a core developer is 
interested in shepherding this change, your proposed change is likely to 
languish.

https://pypi.org/project/cmd2/
https://cmd2.readthedocs.io/en/latest/argument_processing.html

--
nosy: +ned.deily
versions: +Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33224] "RuntimeError: generator raised StopIteration" in difflib.mdiff

2018-04-05 Thread miss-islington

Change by miss-islington :


--
pull_requests: +6099

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33224] "RuntimeError: generator raised StopIteration" in difflib.mdiff

2018-04-05 Thread miss-islington

Change by miss-islington :


--
pull_requests: +6098

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33224] "RuntimeError: generator raised StopIteration" in difflib.mdiff

2018-04-05 Thread Raymond Hettinger

Raymond Hettinger  added the comment:


New changeset 01b731fc2b04744a11e32f93aba8bfb9ddb3dd29 by Raymond Hettinger in 
branch 'master':
bpo-33224: PEP 479 fix for difflib.mdiff() (GH-6381)
https://github.com/python/cpython/commit/01b731fc2b04744a11e32f93aba8bfb9ddb3dd29


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33230] _decimal build failure (unsupported platform for that module) - evolution possible?

2018-04-05 Thread Ned Deily

Ned Deily  added the comment:

> However, this is the first time in 6 years that anyone has reported an OS X 
> build failure.

Yes, I've never seen one before, either.

But I think the culprit is pointed to in the error message.  It looks like you 
have another version of mpdecimal in /usr/local/.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15817] Misc/gdbinit: Expose command documentation to gdb help

2018-04-05 Thread Ned Deily

Ned Deily  added the comment:

Thanks everyone!

--
assignee: dmalcolm -> 
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.8 -Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15817] Misc/gdbinit: Expose command documentation to gdb help

2018-04-05 Thread Ned Deily

Ned Deily  added the comment:


New changeset 7286dbd8b20bd0a26fabe1a07ff368082a9c5ed6 by Ned Deily (Skip 
Montanaro) in branch 'master':
bpo-15817: Expose command documentation to gdb help (GH-6384)
https://github.com/python/cpython/commit/7286dbd8b20bd0a26fabe1a07ff368082a9c5ed6


--
nosy: +ned.deily

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32823] Regression in test -j behavior and time in 3.7.0b1

2018-04-05 Thread Zachary Ware

Zachary Ware  added the comment:

I can't reproduce this.  Even running `python -m test -j14` on a machine with 2 
vCPUs, I get my first results at 2s, and even test___all__ passes in only 6 
(though on my first run, with -j0 (== -j4), test___all__ took 41s but other 
results came in first).  Same results with Debug and Release Win32 builds.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33228] Use Random.choices in tempfile

2018-04-05 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

-0 on making anything other than the doc change.  For the most part, we avoid 
sweeping through the standard library to substitute-in new features and instead 
have a preference for code stability rather than code churn.

FWIW, the main rationale for introducing choices() was to support weighting.  
Existing code that calls choice() multiple times is still correct and clear.

--
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33219] x in IntFlag should test raise TypeError if x is not an IntFlag

2018-04-05 Thread Ethan Furman

Ethan Furman  added the comment:

issue33217 is tracking member-containment checks; modifying this one to track 
class-containment checks.

Given

  class Color(Enum):
 RED = 1

  class Fruit(Enum):
 APPLE = 1

then

  --> Fruit.APPLE in Color
  False
  --> Fruit.APPLE in Fruit
  True
  --> 1 in Fruit
  TypeError

The last is currently returning False instead of raising a TypeError.

--
stage:  -> needs patch
title: x in IntFlag() should test int x's inclusion in IntFlag -> x in IntFlag 
should test raise TypeError if x is not an IntFlag
type: enhancement -> behavior
versions: +Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33203] random.choice: raise IndexError on empty sequence even when not using getrandbits internally

2018-04-05 Thread Raymond Hettinger

Change by Raymond Hettinger :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33203] random.choice: raise IndexError on empty sequence even when not using getrandbits internally

2018-04-05 Thread Raymond Hettinger

Raymond Hettinger  added the comment:


New changeset e25af930a300c01aa043745058a8c7f6c32d89ae by Raymond Hettinger 
(Miss Islington (bot)) in branch '3.6':
bpo-33203: Ensure random.choice always raises IndexError on empty sequence 
(GH-6338) (GH-6388)
https://github.com/python/cpython/commit/e25af930a300c01aa043745058a8c7f6c32d89ae


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33203] random.choice: raise IndexError on empty sequence even when not using getrandbits internally

2018-04-05 Thread Raymond Hettinger

Raymond Hettinger  added the comment:


New changeset baf304e82e1b54dbeee6b78ddf168e33ed8d557a by Raymond Hettinger 
(Miss Islington (bot)) in branch '3.7':
bpo-33203: Ensure random.choice always raises IndexError on empty sequence 
(GH-6338) (GH-6387)
https://github.com/python/cpython/commit/baf304e82e1b54dbeee6b78ddf168e33ed8d557a


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33203] random.choice: raise IndexError on empty sequence even when not using getrandbits internally

2018-04-05 Thread miss-islington

Change by miss-islington :


--
pull_requests: +6097

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33203] random.choice: raise IndexError on empty sequence even when not using getrandbits internally

2018-04-05 Thread miss-islington

Change by miss-islington :


--
pull_requests: +6096

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33203] random.choice: raise IndexError on empty sequence even when not using getrandbits internally

2018-04-05 Thread Raymond Hettinger

Raymond Hettinger  added the comment:


New changeset 091e95e9004b794280ab35becec2c3e30dd5e96e by Raymond Hettinger 
(Wolfgang Maier) in branch 'master':
bpo-33203: Ensure random.choice always raises IndexError on empty sequence 
(GH-6338)
https://github.com/python/cpython/commit/091e95e9004b794280ab35becec2c3e30dd5e96e


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33232] Segmentation fault in operator.attrgetter

2018-04-05 Thread Alexander Sturm

Alexander Sturm  added the comment:

As mentioned, the code is compiled correctly by VS2017 - both in 3.5.5 and 
3.6.5. So I cannot reproduce the issue with Python 3.6.5.

Would it be possible to switch the default platform toolset used to compile 
Python 3.5 in the next source release to v141? According to Microsoft, it 
should be ABI compatible with v140:

https://blogs.msdn.microsoft.com/vcblog/2017/03/07/binary-compatibility-and-pain-free-upgrade-why-moving-to-visual-studio-2017-is-almost-too-easy/

If that's out of the question, I agree that there's probably not much that can 
be done here - other then maybe locally disabling optimizations for that loop.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33232] Segmentation fault in operator.attrgetter

2018-04-05 Thread Zachary Ware

Zachary Ware  added the comment:

Python 3.5 is in security-fix-only mode now, which means we won't be releasing 
any more binaries for it, and thus can't really do much about this other than 
possibly recommending that Windows users build with VS2017 instead of VS2015 in 
future 3.5 release notes.  I believe Python 3.6+ are already built with VS2017, 
but can you reproduce this in Python 3.6.5?

--
components: +Build, Windows
nosy: +larry, paul.moore, steve.dower, tim.golden, zach.ware

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33232] Segmentation fault in operator.attrgetter

2018-04-05 Thread Alexander Sturm

Change by Alexander Sturm :


Added file: https://bugs.python.org/file47522/annotated_dissasembly.txt

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33232] Segmentation fault in operator.attrgetter

2018-04-05 Thread Alexander Sturm

New submission from Alexander Sturm :

This issue can be reproduced using Python 3.5.2 - 3.5.5 compiled with VS2015 
(tested both the official Python builds as well as local builds using VS2015 
Version 14.0.25431.01 Update 3) on 64-bit Windows.

To reproduce, run the attached file (or python -c "import operator; 
operator.attrgetter('x'*100)").

The segfault itself occurs in attrgetter_new [1], while scanning for dots 
inside a unicode string. From my reading of the code, the code itself is 
actually correct - instead, it triggers a compiler bug in VS2015, which causes 
it to miscompile the code by applying an incorrect optimization.

The optimization VS2015 applies is twofold: It uses SIMD instructions to avoid 
looking at every byte of the input string individually, and it tries to 
eliminate the condition in PyUnicode_READ [2] by executing all three branches 
(UCS1, UCS2 and UCS4) at once and then in a separate step discarding the 
results for the two branches that would not be taken.

When combining these optimizations, the generated code incorrectly only checks 
the precondition of the UCS1 branch to decide whether it can use the optimized 
SIMD version. Since the UCS1 branch looks at 8 bytes of the buffer in each 
iteration, it checks whether the buffer contains at least 8 bytes. However, 
each iteration of the UCS2/UCS4 branches look at 16/32 bytes, respectively.

As a result, when passing a UCS1 string to attrgetter(), we end up reading 24 
bytes past the end of the buffer for every 8 bytes the string contains. In the 
reproduction example, we thus read about 24 MB past the buffer, almost 
guaranteeing a crash.

The issue does not occur when compiling Python using VS2017 (i.e. 
PlatformToolset v141, MSVC version 14.13.26128). Presumably this means the 
compiler bug has been fixed upstream.

[1]: https://github.com/python/cpython/blob/v3.5.5/Modules/_operator.c#L587
[2]: https://github.com/python/cpython/blob/v3.5.5/Include/unicodeobject.h#L521

--
components: Interpreter Core
files: repro.py
messages: 314987
nosy: asturm
priority: normal
severity: normal
status: open
title: Segmentation fault in operator.attrgetter
versions: Python 3.5
Added file: https://bugs.python.org/file47521/repro.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33231] Potential memory leak in normalizestring()

2018-04-05 Thread Josh Rosenberg

New submission from Josh Rosenberg :

Patch is good, but while we're at it, is there any reason why this 
multi-allocation design was even used? It PyMem_Mallocs a buffer, makes a 
C-style string in it, then uses PyUnicode_FromString to convert C-style string 
to Python str.

Seems like the correct approach would be to just use PyUnicode_New to 
preallocate the final string buffer up front, then pull out the internal buffer 
with PyUnicode_1BYTE_DATA and populate that directly, saving a pointless 
allocation/deallocation, which also means the failure case means no cleanup 
needed at all, while barely changing the code (aside from removing the need to 
explicitly NUL terminate).

Only reason I can see to avoid this would be if the codec names could contain 
arbitrary Unicode encoded as UTF-8 (and therefore strlen wouldn't tell you the 
final length in Unicode ordinals), but I'm pretty sure that's not the case (if 
it is, we're not normalizing properly, since we only lower case ASCII). If 
Unicode codec names need to be handled, there are other options, though the 
easy savings go away.

--
nosy: +josh.r

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33229] Documentation - io — Core tools for working with streams - seek()

2018-04-05 Thread Mikhail Zakharov

Mikhail Zakharov  added the comment:

OK, I got it. Sorry for disturbing you.

The should be called like: io.SEEK_*

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33229] Documentation - io — Core tools for working with streams - seek()

2018-04-05 Thread Mikhail Zakharov

Mikhail Zakharov  added the comment:

Seems in my, quite old 3.4.5 version, it doesn't work:

$ python3
Python 3.4.5 (default, Jun  1 2017, 13:52:39) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-18)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> f = open('/tmp/text.txt', 'r')
>>> f.seek(0, SEEK_END)
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'SEEK_END' is not defined
>>> f.close()
>>> 
>>> import os
>>> f = open('/tmp/text.txt', 'r')
>>> f.seek(0, os.SEEK_END)
214
>>> f.close()

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6721] Locks in the standard library should be sanitized on fork

2018-04-05 Thread Olivier Chédru

Olivier Chédru  added the comment:

FWIW, I encountered the same kind of issue when using the mkstemp() function: 
under the hood, it calls gettempdir() and this one is protected by a lock too.

Current thread 0x7ff10231f700 (most recent call first):
   File "/usr/lib/python3.5/tempfile.py", line 432 in gettempdir
   File "/usr/lib/python3.5/tempfile.py", line 269 in _sanitize_params
   File "/usr/lib/python3.5/tempfile.py", line 474 in mkstemp

--
nosy: +ochedru

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33229] Documentation - io — Core tools for working with streams - seek()

2018-04-05 Thread Josh Rosenberg

Josh Rosenberg  added the comment:

As indicated in the seek docs ( 
https://docs.python.org/3/library/io.html#io.IOBase.seek ), all three names 
were added to the io module in 3.1:

> New in version 3.1: The SEEK_* constants.

Since they're part of the io module too, there is no need to qualify them on 
the io module docs page.

They're available in os as well, but you don't need to import it to use them. 
The OS specific addition position flags are explicitly documented to be found 
on the os module.

--
nosy: +josh.r

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33231] Potential memory leak in normalizestring()

2018-04-05 Thread INADA Naoki

Change by INADA Naoki :


--
keywords: +patch
pull_requests: +6095
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33231] Potential memory leak in normalizestring()

2018-04-05 Thread INADA Naoki

Change by INADA Naoki :


--
components: Interpreter Core
nosy: inada.naoki
priority: normal
severity: normal
status: open
title: Potential memory leak in normalizestring()
type: resource usage
versions: Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33228] Use Random.choices in tempfile

2018-04-05 Thread Wolfgang Maier

Wolfgang Maier  added the comment:

Actually, in Python2.7 random.choice is implemented with the same 
susceptibility to the rounding bug as Python3's choices, still nobody ever 
reported a tempfile IndexError problem (I guess).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33228] Use Random.choices in tempfile

2018-04-05 Thread Wolfgang Maier

Wolfgang Maier  added the comment:

sorry, should have been issue 24567, of course.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33228] Use Random.choices in tempfile

2018-04-05 Thread Wolfgang Maier

Wolfgang Maier  added the comment:

@serhiy as I understand issue 33228, the double rounding problem potentially 
causing an IndexError can only affect choices() if the len of the sequence to 
choose from is greater than 2049, but the string in question here is only 37 
characters long.
Alternatively, choices may fail with certain weights 
(https://bugs.python.org/msg275594), but _RandomNameSequence is not using 
weights.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33230] _decimal build failure (unsupported platform for that module) - evolution possible?

2018-04-05 Thread Stefan Krah

Stefan Krah  added the comment:

I don't have OS X. However, this is the first time in 6 years that anyone has 
reported an OS X build failure.

Perhaps Ned knows the answer.

--
nosy: +ned.deily, skrah

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33205] GROWTH_RATE prevents dict shrinking

2018-04-05 Thread INADA Naoki

INADA Naoki  added the comment:

@Mark.Shannon, @rhettinger How do you think this?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33230] _decimal build failure (unsupported platform for that module) - evolution possible?

2018-04-05 Thread Hubert Holin

New submission from Hubert Holin :

_decimal fails to build on my platform due to lack of support:

In file included from 
/Developer/Python/3.6/Python/Python-3.6.5/Modules/_decimal/_decimal.c:34:
/usr/local/include/mpdecimal.h:201:4: error: "unsupported platform: need 
mpd_size_t == mpd_uint_t"
  #error "unsupported platform: need mpd_size_t == mpd_uint_t"

My host system type: x86_64-apple-darwin17.5.0
My target system type: x86_64-apple-darwin17.5.0
Compiler used: clang+llvm-6.0.0-x86_64-apple-darwin
Hardware: 3,7 GHz Quad-Core Intel Xeon E5

Relevant configurations:

--enable-universalsdk... 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk

--with-universal-archs... intel

MACHDEP... darwin

Could this module be upgraded?

--
components: Extension Modules
messages: 314976
nosy: Hubert Holin
priority: normal
severity: normal
status: open
title: _decimal build failure (unsupported platform for that module) - 
evolution possible?
type: compile error
versions: Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33228] Use Random.choices in tempfile

2018-04-05 Thread INADA Naoki

INADA Naoki  added the comment:

@wolma Would you split your PR?  One for fix docstring and one for using 
Random.choices.

Since former is document bug, I want to backport it. (while _RandomNameSequence 
is private)

--
nosy: +inada.naoki

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33228] Use Random.choices in tempfile

2018-04-05 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

See issue24567. It affects Random.choices(), but not Random.choice() because 
the latter uses getrandbits().

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15817] Misc/gdbinit: Expose command documentation to gdb help

2018-04-05 Thread Skip Montanaro

Change by Skip Montanaro :


--
versions: +Python 3.7 -Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15817] Misc/gdbinit: Expose command documentation to gdb help

2018-04-05 Thread Skip Montanaro

Skip Montanaro  added the comment:

This looks good to me. I added a pull request with a couple minor tweaks. 
Unfortunately, I can't tell how to add a "skip news" label. This doesn't seem 
"big" enough to warrant it.

--
nosy: +skip.montanaro

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15817] Misc/gdbinit: Expose command documentation to gdb help

2018-04-05 Thread Skip Montanaro

Change by Skip Montanaro :


--
pull_requests: +6094
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15257] Misc/.gdbinit:pystack is too brittle

2018-04-05 Thread Skip Montanaro

Skip Montanaro  added the comment:

I would prefer if these macros remain standalone (and thus fragile). Despite 
Python support in gdb, not everyone (more than five years after the bug report) 
don't use a gdb which was built --with-python. There is better support for gdb 
integration elsewhere in the CPython code base: Tools/gdb/libpython.py.

--
nosy: +skip.montanaro
resolution:  -> rejected
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33229] Documentation - io — Core tools for working with streams - seek()

2018-04-05 Thread Mikhail Zakharov

New submission from Mikhail Zakharov :

Documentation for io.IOBase class and it's seek() method at 
https://docs.python.org/3/library/io.html mentions SEEK_* constants like:

"SEEK_SET or 0 – start of the stream (the default); offset should be zero 
or positive
SEEK_CUR or 1 – current stream position; offset may be negative
SEEK_END or 2 – end of the stream; offset is usually negative
"

It seems, they actually should be used as os.SEEK_SET, os.SEEK_CUR and 
os.SEEK_END.

--
assignee: docs@python
components: Documentation
messages: 314970
nosy: Mikhail Zakharov, docs@python
priority: normal
severity: normal
status: open
title: Documentation -  io — Core tools for working with streams - seek()
type: enhancement
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33195] PyArg_Parse* should deprecate 'u' and 'z' family.

2018-04-05 Thread INADA Naoki

INADA Naoki  added the comment:


New changeset 29bc6f6347b1e05b22180fd296013bb2a104d589 by INADA Naoki in branch 
'3.6':
bpo-33195: Doc: Deprecate Py_UNICODE in c-api/arg (GH-6329)
https://github.com/python/cpython/commit/29bc6f6347b1e05b22180fd296013bb2a104d589


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33211] lineno and col_offset are wrong on function definitions with decorators

2018-04-05 Thread Ivan Levkivskyi

Change by Ivan Levkivskyi :


--
nosy: +levkivskyi

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33228] Use Random.choices in tempfile

2018-04-05 Thread Wolfgang Maier

Change by Wolfgang Maier :


--
keywords: +patch
pull_requests: +6093
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33228] Use Random.choices in tempfile

2018-04-05 Thread Wolfgang Maier

New submission from Wolfgang Maier :

A rather trivial change: tempfile._RandomNameSequence could make use of
random.Random.choices introduced in 3.6.
IMO, the suggested change would give clearer and also faster code.
It also updates the docstring of the class, which currently talks about
a six-character string, when an eight-character string gets returned.

--
messages: 314969
nosy: wolma
priority: normal
severity: normal
status: open
title: Use Random.choices in tempfile
type: performance
versions: Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33195] PyArg_Parse* should deprecate 'u' and 'z' family.

2018-04-05 Thread INADA Naoki

Change by INADA Naoki :


--
pull_requests: +6092

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33211] lineno and col_offset are wrong on function definitions with decorators

2018-04-05 Thread Nitish

Change by Nitish :


--
nosy: +nitishch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33222] Various test failures if PYTHONUSERBASE is not canonicalized

2018-04-05 Thread Nitish

Change by Nitish :


--
nosy: +nitishch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33227] Cmd do_something only accepts one argument

2018-04-05 Thread Oz Tiram

Change by Oz Tiram :


--
components: +Library (Lib)
type:  -> enhancement

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33224] "RuntimeError: generator raised StopIteration" in difflib.mdiff

2018-04-05 Thread Raymond Hettinger

Change by Raymond Hettinger :


--
versions: +Python 3.6, Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33224] "RuntimeError: generator raised StopIteration" in difflib.mdiff

2018-04-05 Thread Raymond Hettinger

Change by Raymond Hettinger :


--
keywords: +patch
pull_requests: +6091
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33227] Cmd do_something only accepts one argument

2018-04-05 Thread Oz Tiram

New submission from Oz Tiram :

Considering that I want to build an CLI interactive program using cmd.Cmd,
which has multiple functions that accept two or more arguments,
I always have to do parsing of arg inside my do_methods for example:

class Calc(cmd.Cmd):

do_add(self, arg):
   a, b = parse_ints(arg)
   return a+b

do_mult(self, arg):
   a, b = parse_ints(arg)
   return a*b

This is easy enough for a simple calculator. But for more logic I need to 
create more parse_type and explicitly call them at the top of each do_stuff.
Considering this I have created a patch for Cmd.cmd, that keeps the old 
functionality, but adds the ability to pass multiple arguments without having 
to parse them every time. 
  
The functionality is as follows:


class MyProg(cmd.Cmd):

do_simple(self, arg):
   print(arg)

do_greet(self, name="World")
   print("Hello %s" %s)

do_add(self, a, b):
   print(a+b)


Now in the cmd prompt:

(Cmd) simple foo
foo  
(Cmd) # keeps the old functionallity 
(Cmd) add 2 3
5
# add two properly add the values
(Cmd) add 2
# expects two arguments, so it will print the help for add
(Cmd) greet
Hello World
# does not complain because it has a default value
(Cmd) greet Guido
Hello Guido
(Cmd) greet name=Raymond
Hello Raymond
# works too

None of these example guess the type. It is simply handles as a string. but I 
am playing around with automatically detecting types of variables using 
function annotations in python 3.5 and later.

Also, although, not demonstrated here, one can also define:

def do_some_method_with_kwargs(self, arg1, arg2, **kwargs):
... do fancy stuff ...

(Cmd) some_method_with_kwargs foo bar kwargs='{"name": "John", "age"=35}'

kwargs is parsed to a dict (using json.loads) when escaped properly.
This is a bit esoteric, hence not shown here (but the patch patch includes it).
 
I was wondering if this kind of enhancement would be considered for this 
module? 
I will happily create a PR with tests and documentation explaining this 
enhanced functionality.

--
files: cmd.patch
keywords: patch
messages: 314968
nosy: Oz.Tiram
priority: normal
severity: normal
status: open
title: Cmd do_something only accepts one argument
Added file: https://bugs.python.org/file47520/cmd.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33224] "RuntimeError: generator raised StopIteration" in difflib.mdiff

2018-04-05 Thread Raymond Hettinger

Change by Raymond Hettinger :


--
assignee:  -> rhettinger
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com