[issue25507] IDLE: user code 'import tkinter; tkinter.font' should fail

2015-10-29 Thread Roundup Robot

Roundup Robot added the comment:

New changeset a37ea1d56e98 by Terry Jan Reedy in branch '2.7':
Issue #25507: move test-specific imports to test function (idlelib.IOBinding).
https://hg.python.org/cpython/rev/a37ea1d56e98

New changeset 38b6b7253ba1 by Terry Jan Reedy in branch '3.4':
Issue #25507: move test-specific imports to test function (idlelib.IOBinding).
https://hg.python.org/cpython/rev/38b6b7253ba1

--
nosy: +python-dev

___
Python tracker 

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



[issue8231] Unable to run IDLE without write-access to home directory

2015-10-29 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Without being able to make my homedir read-only, I don't, of course, see the 
messages.  Since run does not use idleConf (I am now sure), you should have 
been able to proceed after clicking away the admittedly obnoxious repeat 
messages.  The old extraneous user-process temporary should disappear when you 
restart.  Can you check that?

--

___
Python tracker 

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



[issue25507] IDLE: user code 'import tkinter; tkinter.font' should fail

2015-10-29 Thread Terry J. Reedy

Terry J. Reedy added the comment:

The subprocess command is built in PyShell.ModifiedInterpreter method 
build_subprocess_arglist (l.404). It imports run and calls run.main(args).

The test for this issue would be to import run and check that sys.modules does 
not contain configHandler and that tkinter does not contain any of its possible 
submodules.

--
stage: needs patch -> test needed

___
Python tracker 

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



[issue25507] IDLE: user code 'import tkinter; tkinter.font' should fail

2015-10-29 Thread Terry J. Reedy

Terry J. Reedy added the comment:

To continue: CallTips.Calltips has a similar here-or-there logic that decides 
where to execute the actual get-calltip-logic.  In this case,  get_entity and 
get_argspec are already functions rather than methods (I changed get_entity 
from method to function in 02b4c62ce393.) The functions could be moved into a 
different module with the completions function.

RemoteDebugger imports Debugger which imports WindowList, ScrolledList, and 
macosxSupport, all without idleConf imports.

RemoteObjectBrowser import rpc, both without idleConf.  run also imports rpc.

StackViewer imports TreeWidget and ObjectBrowser, which are not issues.  It 
also imports PyShell for PyShellFileList, which would be an issue, except that 
this is only for the htest function _stack_viewer.  I will move the 
test-specific import into the function, as is my current policy.

IOBinding is imported for IOBinding.encoding. The code that calculates this 
could be put anywhere.  This is fortunate because IOBinding imports idleConf 
and three tkinter modules.

Conclusion: moving about 2-300 lines of code (about 6 objects) from PyShell, 
AutoComplete, and IOBinding into run (currently about 400 lines) would 
eliminate idleConf from the user process.  I did not check tkinter imports for 
all the above, but it might also fix the tkinter namespace problem.

--

___
Python tracker 

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



[issue25507] IDLE: user code 'import tkinter; tkinter.font' should fail

2015-10-29 Thread Terry J. Reedy

Terry J. Reedy added the comment:

#8231 will benefit if indirect imports of configHandler and idleConf into the 
user process can be eliminated.  I do not currently believe it is needed.  Not 
importing PyShell will go part way.

AutoComplete imports idleConf to get the popup delay. run imports AutoComplete 
to access fetch_completions -- in particular, the part after 'else', after the 
logic to determine which process the code is in and if in the idle process, 
whether to fetch in the idle process (-n) or user process.  Fetch_completions 
is a function and not properly a method -- it only uses self to access 
get_entity.  Get_entity is a two line function the also should not be a method. 
 It is only called at the one place and the only reason to not put in inline 
would be for testing.  The code after 'else' could be made a function in a 
separate module and the AutoComplete import eliminated.

CallTip does not import idleConf, nor does CallTipWindow or HyperParser or 
PyParse.

--
components: +IDLE

___
Python tracker 

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



[issue25504] undefined name 'modules' in Tools/freeze/checkextensions_win32.py

2015-10-29 Thread Benjamin Peterson

Changes by Benjamin Peterson :


--
resolution:  -> fixed
status: open -> closed

___
Python tracker 

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



[issue25504] undefined name 'modules' in Tools/freeze/checkextensions_win32.py

2015-10-29 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 31fd613a40aa by Benjamin Peterson in branch '2.7':
fix usage of undefined name (#25504)
https://hg.python.org/cpython/rev/31fd613a40aa

New changeset 114fb81a08e3 by Benjamin Peterson in branch '3.4':
fix usage of undefined name (#25504)
https://hg.python.org/cpython/rev/114fb81a08e3

New changeset e6ab376f575e by Benjamin Peterson in branch '3.5':
merge 3.4 (#25504)
https://hg.python.org/cpython/rev/e6ab376f575e

New changeset 2de616269f0e by Benjamin Peterson in branch 'default':
merge 3.5 (#25504)
https://hg.python.org/cpython/rev/2de616269f0e

--
nosy: +python-dev

___
Python tracker 

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



[issue8231] Unable to run IDLE without write-access to home directory

2015-10-29 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I cannot currently think of any reason why the subprocess *needs* to access 
idleConf, so I want to put this on hold while investigating whether the 
accesses can be eliminated as part of #25507.

--
dependencies: +IDLE: user code 'import tkinter; tkinter.font' should fail

___
Python tracker 

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



[issue25515] Always use os.urandom for generating uuid4s

2015-10-29 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 24bdc4940e81 by Benjamin Peterson in branch '2.7':
always use os.urandom for the uuid4 algorithm (closes #25515)
https://hg.python.org/cpython/rev/24bdc4940e81

New changeset 70be1f9c9255 by Benjamin Peterson in branch '3.5':
always use os.urandom for the uuid4 algorithm (closes #25515)
https://hg.python.org/cpython/rev/70be1f9c9255

New changeset 756d040aa8e8 by Benjamin Peterson in branch 'default':
merge 3.5 (#25515)
https://hg.python.org/cpython/rev/756d040aa8e8

--
nosy: +python-dev
resolution:  -> fixed
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



[issue25482] signal.set_wakeup_fd() doesn't work if the signal don't have handler

2015-10-29 Thread Atsuo Ishimoto

Atsuo Ishimoto added the comment:

Thank you for good sample. This should be written in PEP 475.

But installing new signal handler can cause different behavior. 

As in my previous example, if other 3rd party libraries(ncurses in my case) 
need to handle the signal, signal is consumed by Python handler and not 
delivered to the library.

--

___
Python tracker 

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



[issue25482] signal.set_wakeup_fd() doesn't work if the signal don't have handler

2015-10-29 Thread STINNER Victor

STINNER Victor added the comment:

It's very easy to get the same behaviour on Python 3.4 (without PEP 475) and 
Python 3.5 (with PEP 475). Just add the following code at the top of your 
example:

import signal

def sighandler(signum, frame):
raise InterruptedError

signal.signal(signal.SIGWINCH, sighandler)
---

You can use any Python exception, not only InterruptedError.

PEP 475 only changes the behaviour on signals with an handler which doesn't 
raise an exception.

--

___
Python tracker 

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



[issue25495] binascii documentation incorrect

2015-10-29 Thread Martin Panter

Martin Panter added the comment:

Thanks for bringing this up, it has often bugged me.

My understanding, based on the original wording and places where this is used, 
is that the data is often pre-processed into 57-byte chunks, rather than 
post-processing it. Maybe it is worthwhile restoring that info. It should help 
understanding the presence of the newline parameter (or why a newline is always 
added in 3.5).

Also, the link between RFC 4648 and this function could be made even more 
explicit. Maybe move “as defined” into the first sentence, or change “the 
Base64 output” to “the function’s output”.

--
nosy: +martin.panter
stage:  -> patch review
versions: +Python 2.7, Python 3.4, Python 3.6

___
Python tracker 

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



[issue25516] threading.Condition._is_owned() is wrong when using threading.Lock

2015-10-29 Thread Nir Soffer

Changes by Nir Soffer :


--
keywords: +patch
Added file: 
http://bugs.python.org/file40900/0001-Issue-25516-threading.Condition._is_owned-fails-when.patch

___
Python tracker 

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



[issue25512] apparent memory leak using ctypes

2015-10-29 Thread Martin Panter

Martin Panter added the comment:

I am running your script with the Python 3.5.0 from Arch Linux on an x86-64 
computer. The reported numbers slowly increase and then plateau at 221 million:

$ python ctype_stressor.py
   1  0.000e+00  3.8010880e+07
  10  2.8538793e+00  1.4648934e+08
  20  2.9961207e+00  1.5189606e+08
  30  3.1383621e+00  1.5730278e+08
  40  3.2806034e+00  1.6270950e+08
  50  3.4512931e+00  1.6919757e+08
  60  3.5935345e+00  1.7460429e+08
  70  3.7357759e+00  1.8001101e+08
  80  3.8780172e+00  1.8541773e+08
  90  4.0202586e+00  1.9082445e+08
 100  4.1909483e+00  1.9731251e+08
 110  4.3331897e+00  2.0271923e+08
 120  4.4754310e+00  2.0812595e+08
 130  4.6176724e+00  2.1353267e+08
 140  4.7599138e+00  2.1893939e+08
 150  4.7883621e+00  2.2002074e+08
 160  4.7883621e+00  2.2002074e+08
. . .
 270  4.7883621e+00  2.2002074e+08
 280  4.8043103e+00  2.2062694e+08
. . .
 410  4.8043103e+00  2.2062694e+08
 420  4.8133621e+00  2.2097101e+08
. . .
1300  4.8133621e+00  2.2097101e+08

Monitoring the process with “htop”, I see the total virtual memory (VIRT) 
ramping up to about 79 MiB, and then jumping back to about 62 MiB, and the 
resident physical memory (RES) ramps within 36–53 MiB in a similar pattern.

Similarly, Python 2.7.10 ramps within RES = 32–43 MiB, and your script is 
showing 177 million:

1140  5.5962126e+00  1.7691443e+08

Is this the same as what you are seeing? How long do you have to you run your 
script for?

The memory figures in your script seem to be out by a factor of four, assuming 
the third column is meant to be a number of bytes. But I don’t think there is a 
memory leak. At worst there is an unexpected dependency cycle between objects, 
meaning the memory builds up a bit until the garbage collector runs.

--
nosy: +martin.panter
versions: +Python 2.7

___
Python tracker 

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



[issue25516] threading.Condition._is_owned() is wrong when using threading.Lock

2015-10-29 Thread Nir Soffer

Nir Soffer added the comment:

The issue was introduced in this commit:

commit 8cb1ccbb8b9ed01c26d2c5be7cc86682e525dce7
Author: Guido van Rossum 
Date:   Thu Apr 9 22:01:42 1998 +

New Java-style threading module.  The doc strings are in a separate module.

--

___
Python tracker 

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



[issue25515] Always use os.urandom for generating uuid4s

2015-10-29 Thread Donald Stufft

Donald Stufft added the comment:

This looks like a good idea to me, faster and more secure seems like a total 
win.

--

___
Python tracker 

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



[issue25514] better startup error messages in IDLE when stdlib modules shadowed

2015-10-29 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Either tkinter and tkinter.messagebox or subprocess must be imported to display 
a message when IDLE is started from an icon, and there is no console.  With 
subprocess, '''python -i -c "print('Cannot start IDLE (or whatever)')"''' 
should work.  If nothing else, this would be a way to display a message when 
import tkinter fails.

--

___
Python tracker 

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



[issue25514] better startup error messages in IDLE when stdlib modules shadowed

2015-10-29 Thread Terry J. Reedy

Terry J. Reedy added the comment:

"I think that removing '' from sys.path, so that IDLE can run, is better than a 
nicer warning that it cannot run. This, of course, requires that sys not be 
shadowed, so that sys.path can be accessed."  So after importing sys, we should 
check sys.__file__, or do the manipulation in try: except: .  This will be part of a much more careful startup sequence.

--

___
Python tracker 

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



[issue25514] better startup error messages in IDLE when stdlib modules shadowed

2015-10-29 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Laura, I did not understand from your python-list post that you were 
complaining about shadowing disabling IDLE itself, as opposed to user code.  
That is partly because you followed up on Peter Otten complaining because IDLE 
tries to run user code the same way that python does.

The solution for IDLE itself is for IDLE to do what python does on startup, 
which is to ensure that the stdlib modules it needs are indeed imported from 
the stdlib.  I presume that python only prepends '' to sys.path *after* it does 
its imports.  Example:

>>> import sys; list(sys.modules)
[..., abc, ...]
C:\Users\Terry>echo "print('abc')" >abc  # verified with dir
C:\Users\Terry>python
>>> >>> import sys; sys.modules['abc'].__file__
'C:\\Programs\\Python35\\lib\\abc.py'

So IDLE should remove sys.path[0] from sys.path and, in the user process, 
restore it only after normal imports. Ignore -n single process mode for now.

Aside from this, the popup message needs to be changed, but better that it 
occur less often (by the fix above) or never (by switching to pipes?).

As for user code: I have in mind that there should be a doc how-to about 
tracebacks and exception messages, with a sections giving possible explanations 
and remedies for specific messages, such as the above.  This I would make 
messages like the above a link to the how-to entry.  In the meanwhile, we could 
consider a special case search of error message lines.

-I just noticed that this issue is the result of a pydev thread. Off to read 
that.

--
stage:  -> needs patch
type: enhancement -> behavior
versions: +Python 3.4

___
Python tracker 

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



[issue25516] threading.Condition._is_owned() is wrong when using threading.Lock

2015-10-29 Thread Nir Soffer

New submission from Nir Soffer:

When using threading.Lock, threading.Condition._is_owned is assuming that the 
calling thread is owning the condition lock if the lock cannot be acquired. 
This check is completely wrong if another thread owns the lock.

>>> cond = threading.Condition(threading.Lock())
>>> threading.Thread(target=cond.acquire).start()
>>> cond._is_owned()
True
>>> cond.notify()
>>> cond.wait(0)
False

Careful users that acquire the condition before calling wait() or notify() are 
not effected. Careless users that should have been warned by RuntimeError are.

Tested on Python 2.7 and 3.4.2 and 3.6.0a0.

--
components: Library (Lib)
messages: 253703
nosy: nirs
priority: normal
severity: normal
status: open
title: threading.Condition._is_owned() is wrong when using threading.Lock
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6

___
Python tracker 

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



[issue25498] Python 3.4.3 core dump with simple sample code

2015-10-29 Thread Martin Panter

Martin Panter added the comment:

Before the Issue 22896 changes, PyObject_AsWriteBuffer() was used, which 
requests a buffer with the PyBUF_WRITABLE flag. Currently we use “w*” argument 
parsing format, which also uses PyBUF_WRITABLE. (Incidentally, I suspect the 
C-contiguity check is redundant for “w*”; non-contiguous buffers trigger the 
“read-write” error instead.)

Now Eryksun’s patch changes to PyMemoryView_FromObject(), which requests a 
buffer with the PyBUF_FULL_RO flag (the most liberal), and only then checks for 
writability and contiguity. Could this be a problem for some kind of object 
that returns different buffers depending on the request flags?

I agree that the existing buffer and memory view APIs don’t seem to be very 
practical and well understood. PyMemoryView_FromBuffer() is also used in the 
“io” module. It doesn’t even try to save a reference to the underlying buffers, 
meaning it is possible for Python code to write into freed memory by saving the 
memory view object passed to the readinto() method.

--

___
Python tracker 

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



[issue25156] shutil.copyfile should internally use os.sendfile when possible

2015-10-29 Thread desbma

desbma added the comment:

I played a bit with Unix domain sockets, and it appears you can not open them 
like a file with open().
So they do no work with the current implementation of shutil.copyfile anyway.

--

___
Python tracker 

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



[issue11796] Comprehensions in a class definition mostly cannot access class variable

2015-10-29 Thread Anne Rosa Wangnick

Anne Rosa Wangnick added the comment:

With https://bugs.python.org/issue13557 closed, this one should be reopened to 
amend 6.2.8 Generator expressions: "[However, the leftmost for clause is 
immediately evaluated] (in the local context)[, so that an error produced by it 
can be seen ...]"

--
nosy: +Anne Rosa Wangnick

___
Python tracker 

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



[issue25515] Always use os.urandom for generating uuid4s

2015-10-29 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

On Oct 29, 2015, at 10:30 PM, Alex Gaynor wrote:

>Right now uuid4 can be implemented one of 3 ways:

If you're hacking on the uuid module, keep in mind issue22807

--
nosy: +barry

___
Python tracker 

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



[issue25515] Always use os.urandom for generating uuid4s

2015-10-29 Thread John Mark Vandenberg

Changes by John Mark Vandenberg :


--
nosy: +John.Mark.Vandenberg

___
Python tracker 

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



[issue25515] Always use os.urandom for generating uuid4s

2015-10-29 Thread Alex Gaynor

Alex Gaynor added the comment:

(Note that the speed difference would be even bigger on a recent python, 2.7.3 
was before the file descriptor was cached for os.urandom)

--

___
Python tracker 

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



[issue25515] Always use os.urandom for generating uuid4s

2015-10-29 Thread Alex Gaynor

New submission from Alex Gaynor:

Right now uuid4 can be implemented one of 3 ways:

- If there's a libuuid (and it's not OS X's) it uses that.
- Fallback to os.urandom
- If that raises an exception, fall back to the random module

I propose to simplify this to _just_ use os.urandom always. Reasons:

- Its security properties are more obviously correct. (There's a large comment 
in uuid.py about how libuuid doees the wrong thing with fork on OS X, who knows 
if it's correct on other platforms)
- It's simpler.
- It's faster:

a_gaynor@miranda:~$ python -mtimeit -s "import uuid; import os; import ctypes" 
"_buffer = ctypes.create_string_buffer(16); 
uuid._uuid_generate_random(_buffer); bytes(_buffer.raw)"
10 loops, best of 3: 10 usec per loop
a_gaynor@miranda:~$ python -mtimeit -s "import uuid; import os; import ctypes" 
"_buffer = ctypes.create_string_buffer(16); 
uuid._uuid_generate_random(_buffer); bytes(_buffer.raw)"
10 loops, best of 3: 10.3 usec per loop
a_gaynor@miranda:~$ python -mtimeit -s "import uuid; import os; import ctypes" 
"_buffer = ctypes.create_string_buffer(16); 
uuid._uuid_generate_random(_buffer); bytes(_buffer.raw)"
10 loops, best of 3: 9.99 usec per loop
a_gaynor@miranda:~$ python -mtimeit -s "import uuid; import os; import ctypes" 
"_buffer = ctypes.create_string_buffer(16); 
uuid._uuid_generate_random(_buffer); bytes(_buffer.raw)"
10 loops, best of 3: 10.2 usec per loop
a_gaynor@miranda:~$ python -mtimeit -s "import uuid; import os; import ctypes" 
"_buffer = ctypes.create_string_buffer(16); 
uuid._uuid_generate_random(_buffer); bytes(_buffer.raw)"
10 loops, best of 3: 10.2 usec per loop
a_gaynor@miranda:~$
a_gaynor@miranda:~$
a_gaynor@miranda:~$
a_gaynor@miranda:~$
a_gaynor@miranda:~$ python -mtimeit -s "import uuid; import os; import ctypes" 
"os.urandom(16)"
10 loops, best of 3: 8.94 usec per loop
a_gaynor@miranda:~$ python -mtimeit -s "import uuid; import os; import ctypes" 
"os.urandom(16)"
10 loops, best of 3: 8.92 usec per loop
a_gaynor@miranda:~$ python -mtimeit -s "import uuid; import os; import ctypes" 
"os.urandom(16)"
10 loops, best of 3: 8.97 usec per loop
a_gaynor@miranda:~$ python -mtimeit -s "import uuid; import os; import ctypes" 
"os.urandom(16)"
10 loops, best of 3: 8.93 usec per loop
a_gaynor@miranda:~$ python -mtimeit -s "import uuid; import os; import ctypes" 
"os.urandom(16)"
10 loops, best of 3: 8.94 usec per loop
a_gaynor@miranda:~$
a_gaynor@miranda:~$
a_gaynor@miranda:~$ python --version
Python 2.7.3

--
components: Library (Lib)
files: uuid.diff
keywords: needs review, patch
messages: 253697
nosy: alex, dstufft
priority: normal
severity: normal
status: open
title: Always use os.urandom for generating uuid4s
versions: Python 2.7, Python 3.5, Python 3.6
Added file: http://bugs.python.org/file40899/uuid.diff

___
Python tracker 

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



[issue25041] document AF_PACKET socket address format

2015-10-29 Thread Camilla Montonen

Camilla Montonen added the comment:

Provided patch provides documentation for the AF_PACKET address_family.

--
keywords: +patch
nosy: +Winterflower
Added file: http://bugs.python.org/file40898/af_packet_doc.patch

___
Python tracker 

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



[issue25514] better startup error messages in IDLE when stdlib modules shadowed

2015-10-29 Thread Laura Creighton

Laura Creighton added the comment:

s/machines will/machines with/

(I was tired.)

--

___
Python tracker 

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



[issue25514] better startup error messages in IDLE when stdlib modules shadowed

2015-10-29 Thread Laura Creighton

Laura Creighton added the comment:

Note that the full path name of the file that is doing the shadow
is of important interest to teachers.  We get machines will all sorts of 
garbage written on them -- the amount of hell caused by a misnamed turtle.py is 
hard to measure -- and anything as helps in the finding of the file as needs 
removing or renaming will be eternally welcome.

--
nosy: +lac

___
Python tracker 

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



[issue25514] better startup error messages in IDLE when stdlib modules shadowed

2015-10-29 Thread Mark Roseman

New submission from Mark Roseman:

When we create e.g. string.py that shadows a stdlib module needed by IDLE, it 
would be nice if a better error message could be shown, pointing to that cause.

Original message:

lac at smartwheels:~/junk$ echo "print ('hello there')" >string.py
lac at smartwheels:~/junk$ idle-python3.5
hello there
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.5/idlelib/run.py", line 10, in 
from idlelib import CallTips
  File "/usr/lib/python3.5/idlelib/CallTips.py", line 16, in 
from idlelib.HyperParser import HyperParser
  File "/usr/lib/python3.5/idlelib/HyperParser.py", line 14, in 
_ASCII_ID_CHARS = frozenset(string.ascii_letters + string.digits + "_")
AttributeError: module 'string' has no attribute 'ascii_letters'

IDLE then produces a popup that says:

IDLE's subprocess didn't make connection.  Either IDLE can't stat a subprocess 
por personal firewall software is blocking the connection. 



I think that life would be a whole lot easier for people if instead we got
a message:

Warning: local file /u/lac/junk/string.py shadows module named string in the 
Standard Library

I think that it is python exec that would have to do this -- though of
course the popup could also warn about shadowing in general, instead of
sending people on wild goose chases over their firewalls.

--

Laura, I think what you want should actually be more-or-less doable in IDLE.

The main routine that starts IDLE should be able to detect if it starts 
correctly (something unlikely to happen if a significant stdlib module is 
shadowed), watch for an attribute error of that form and try to determine if 
shadowing is the cause, and if so, reissue a saner error message.

The subprocess/firewall error is occurring because the ‘string’ problem in your 
example isn’t being hit right away so a few startup things already are 
happening. The point where we’re showing that error (as a result of a timeout) 
should be able to check as per the above that IDLE was able to start alright, 
and if not, change or ignore the timeout error.

There’ll probably be some cases (depending on exactly what gets shadowed) that 
may be difficult to get to work, but it should be able to handle most things.


See full thread starting at 
https://mail.python.org/pipermail/python-dev/2015-October/142061.html

--
components: IDLE
messages: 253693
nosy: kbk, markroseman, roger.serwy, terry.reedy
priority: normal
severity: normal
status: open
title: better startup error messages in IDLE when stdlib modules shadowed
type: enhancement
versions: Python 2.7, Python 3.5, Python 3.6

___
Python tracker 

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



[issue25501] Use async/await through asyncio docs

2015-10-29 Thread Brett Cannon

Changes by Brett Cannon :


--
resolution:  -> wont fix
status: open -> closed

___
Python tracker 

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



[issue25501] Use async/await through asyncio docs

2015-10-29 Thread Guido van Rossum

Guido van Rossum added the comment:

Honestly I think it's better if most people keep using coroutine/yield-from 
instead of async/await for a few more releases; their code will be more 
portable, since it takes forever to update old datacenters. We put in 
async/await with an eye towards the future. But we're keeping yield-from around 
for a long time too. And that's also why we support asyncio for 3.3.

--

___
Python tracker 

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



[issue25513] collections.abc.Iterable don't implement __bool__

2015-10-29 Thread R. David Murray

R. David Murray added the comment:

This is as designed.  The only method needed for something to qualify as an 
Iterable is __iter__, thus this is the only method defined on the ABC.  If you 
want your Iterable to be usable in a boolean test, add the __bool__ method to 
your concrete class.

In fact, you will note that no ABCs define __bool__.

Likewise __len__ is not part of being an Iterator, and in fact in the general 
case Iterators do not have a len (a given Iterator might be infinite, or it 
might not be practical to calculate the len).

--
nosy: +r.david.murray
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



[issue25513] collections.abc.Iterable don't implement __bool__

2015-10-29 Thread yoch

New submission from yoch:

collections.abc.Iterable don't implement the __bool__ method. This may 
seriously degrade performance in case __len__ is not efficient.

I suggest to implement it as :

class Iterable:
...
def __bool__(self):
try:
next(iter(self))
return True
except StopIteration:
return False

--
components: Library (Lib)
messages: 253690
nosy: yoch.melka
priority: normal
severity: normal
status: open
title: collections.abc.Iterable don't implement __bool__
type: enhancement

___
Python tracker 

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



[issue24778] mailcap.findmatch: document shell command Injection danger in filename parameter

2015-10-29 Thread Bernd Dietzel

Bernd Dietzel added the comment:

My patch for mailcap.py. Please check and apply my patch please.

1) I have removed the os.system() calls for security reasons.

2) New "findmtach_list()" function witch returns the commandline as a [list] 
witch can be passed to subprocess instead of passing it to os.system().

3) New run() function to execute the cmd_list with subprocess. 

4) The test() function now uses findmatch_list() and run() instead of the old 
findmatch() and os.system() calls.  

5) The subst() function is now shorter an does a quote(filename) when its 
replacing %s with a filename.

6) The "old" findmatch() function is still there if the user still likes to 
have the commandline as a "string". 
Attention ! With this old findmatch() function it's still possible that a shell 
command in the filename like '$(ls).txt' will be executed when the users passes 
the string to os.system() outside the mailcap script. Use findmatch() only for 
backwards compatibility.

7) Use the new findmatch_list() an run() for future projects.

8) Add 1)-7) to the docs

Thank you.

--
Added file: http://bugs.python.org/file40897/mailcap patch.zip

___
Python tracker 

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



[issue25512] apparent memory leak using ctypes

2015-10-29 Thread Martin Smith

New submission from Martin Smith:

Attached file demonstrates a memory leak arising in ctypes (I think).  Leak 
occurs in both 2.7 and 3.5, though at different rates.

Humble apologies if I've screwed up somewhere.  Very nervous about submitting 
this.

--
components: ctypes
files: ctype_stressor.py
messages: 253688
nosy: blindgoat
priority: normal
severity: normal
status: open
title: apparent memory leak using ctypes
type: resource usage
versions: Python 3.5
Added file: http://bugs.python.org/file40896/ctype_stressor.py

___
Python tracker 

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



[issue25509] PyImport_ImportModule inaccurately described

2015-10-29 Thread Brett Cannon

Brett Cannon added the comment:

Semantic change was probably because of the lack of import hook support which 
is required since Python 3.3. So the docs just need to be fixed rather than the 
semantics.

--

___
Python tracker 

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



[issue25509] PyImport_ImportModule inaccurately described

2015-10-29 Thread Brett Cannon

Changes by Brett Cannon :


--
nosy: +brett.cannon

___
Python tracker 

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



[issue25489] sys.exit() caught in exception handler

2015-10-29 Thread Brian Sutherland

Brian Sutherland added the comment:

On Wed, Oct 28, 2015 at 02:49:55PM +, R. David Murray wrote:
> 
> R. David Murray added the comment:
> 
> Using sys.exit means you are depending on garbage collection to clean
> up all of your program's resources.  In the general case this is a bad
> idea.  A better design is to call loop.stop, and then do cleanup
> (which might involve calling some wait_closed functions via
> loop.run_until_complete).  If you just call sys.exit, your resources
> may not get cleaned up correctly, or may not get cleaned up correctly
> somewhat randomly due to the indeterminacies in the order in which
> garbage collection is done.  This may not matter for a simple program,
> but I find it makes it easier for me if I just do it "the right way"
> always :)

I think it depends on the problem, sometimes "crash-only" software is
safer. You have to design for immediate failure anyway, can't stop those
pesky hardware failures. So if you always immediately crash there is
only one, well-tested path to stopping a program.

Also saves a lot of cleanup code writing;)

Hmm, I suppose that means I should really be using os._exit(42) to avoid
garbage collection...

--

___
Python tracker 

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



[issue25469] multiprocessing .Condition.notify(_all) function has O(N) time complexity where N is the number of wait() calls with a timeout since the last notify(_all) call

2015-10-29 Thread Vilnis Termanis

Vilnis Termanis added the comment:

I realise that having type bug type of "performance" means it's less likely to 
be looked at than if I had marked is as "behaviour" or "resource usage" (which 
would not be completely unfair, I think).

Also, the patch should be applicable to 2.7 and 3.2 through to 3.5 (despite 
versions having been removed from the bug report).

--

___
Python tracker 

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



[issue17006] Add advice on best practices for hashing secrets

2015-10-29 Thread Joshua Bronson

Changes by Joshua Bronson :


--
nosy: +jab

___
Python tracker 

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



[issue25501] Use async/await through asyncio docs

2015-10-29 Thread Brett Cannon

Brett Cannon added the comment:

Once 3.4.4 launches the need to keep the docs synced with a version that 
doesn't support async/await goes away. And worrying about 3.3 isn't necessary 
since asyncio was added in 3.4.

So once 3.4.4 is released and we close the 3.4 branch to bugfixes can we update 
the docs in asyncio and add a note at the top saying the examples all use 
async/await from 3.5 and if you need 3.4 compatibility to please look at the 
3.4 docs? Otherwise how long do you want to wait until we can start using 
async/await in the documentation? My worry is that people are going to blindly 
copy the examples and tweak them for their needs since the asyncio docs are a 
bit dense and thus just simply overlook the fact that async/await exists.

--

___
Python tracker 

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



[issue25507] IDLE: user code 'import tkinter; tkinter.font' should fail

2015-10-29 Thread Mark Roseman

Mark Roseman added the comment:

This (restructuring/refactoring to minimize the subprocess imports) does 
definitely sound like the right approach. There will be other benefits to 
breaking up PyShell a bit too..

--

___
Python tracker 

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



[issue25498] Python 3.4.3 core dump with simple sample code

2015-10-29 Thread Stefan Krah

Stefan Krah added the comment:

We should ultimately do something like I suggested in msg235256.

Everything else is a hack (N.B.: the issues that 1da9630e9b7f
tried to fix were also hacks, so it isn't really the fault of
that commit).

--
nosy: +skrah

___
Python tracker 

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



[issue8231] Unable to run IDLE without write-access to home directory

2015-10-29 Thread Mark Roseman

Mark Roseman added the comment:

Better, but alas still not quite. On further investigation, the issue is that a 
new instance of idleConf is instantiated in the subprocess, which then calls 
mkdtemp() returning a different name. You can see this by doing 'restart shell' 
and noting that it will hit the warning you added in GetUserCfgDir.

There are multiple places that the subprocess does access preferences, so just 
eliminating them is probably not the right way to go.

I'd probably recommend that the user prefs dir be communicated to the 
subprocess somehow. Two suggestions are via adding a command line parameter 
where we launch the subprocess (build_subprocess_arglist), or have the 
subprocess get it via 'remotecall' when it starts up (perhaps in 
MyHandler.handle). Either way this would then need to be communicated to 
idleConf so it uses that directory.

Would there be a preference and/or any other alternatives?

--

___
Python tracker 

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



[issue25510] fileinput.FileInput.readline() always returns str object at the end even if in 'rb' mode

2015-10-29 Thread R. David Murray

R. David Murray added the comment:

We need to think carefully about backward compatibility here.

--
nosy: +r.david.murray

___
Python tracker 

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



[issue25511] multiprocessing pool blocks SIGTERM from being handled

2015-10-29 Thread David Jones

New submission from David Jones:

This is probably related to #21913, but more specifically concerns the 
documentation. I have a sub process of a larger program that handles a SIGTERM 
sent by the main process for a clean shutdown. However, if I launch a parallel 
task in the sub process, via multiprocessing.Pool.imap_unordered, all signals 
are blocked until pool finishes running the task. 

If this isn't going to be fixed, then it ought to at least be clearly 
documented. It took a very long time to diagnose this problem. It requires a 
programmer to understand the underlying implementation of a high-level 
construct, thus defeating the purpose of using a high level construct.

Also, is there a way to work around this?

--
assignee: docs@python
components: Documentation
messages: 253678
nosy: djones, docs@python
priority: normal
severity: normal
status: open
title: multiprocessing pool blocks SIGTERM from being handled
type: behavior
versions: Python 2.7

___
Python tracker 

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



[issue25510] fileinput.FileInput.readline() always returns str object at the end even if in 'rb' mode

2015-10-29 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Would be nice to add a test in Lib/test/test_fileinput.py.

--
nosy: +serhiy.storchaka
stage:  -> test needed

___
Python tracker 

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



[issue25482] signal.set_wakeup_fd() doesn't work if the signal don't have handler

2015-10-29 Thread Atsuo Ishimoto

Atsuo Ishimoto added the comment:

> Benjamin Peterson added the comment:
> 
> The OP probably wants something like the Linux-specific signalfd() syscall.

Yes.

Long explanation:

I have an console text editor written in 
Python/curses(http://kaaedit.github.io/).

This editor didn't work with Python 3.5 because select.select() stop raising 
InterruptedError.

Following is sample code to reproduce. This code displays size of terminal. If 
you resize your terminal, screen is updated and new size is displayed.

---

import curses, select, sys

def main(stdscr):
i=0
while True:
y, x = stdscr.getmaxyx()
stdscr.addstr(i % 10, 0, "%d x:%d y:%d" % (i, x, y))
i+=1
stdscr.refresh()
try:
s=select.select([sys.stdin], [], [])   # wait for user input and 
some sockets.
except InterruptedError:
stdscr.addstr(i % 10, 0, "%d InterruptedError" % i)
i+=1
continue
try:
c=stdscr.get_wch()
except curses.error:
stdscr.addstr(i % 10, 0, "%d curses.error" % i)
i+=1
continue
if c == 'q':
break

curses.wrapper(main)

---

Resizing terminal generates SIGIWNCH signal. In Python 3.4, select.select() 
raises InterruptedError when the signal sent. Also, Ncurses library catches the 
signal and update internal data to reflect new terminal size.

To detect resizing in Python 3.5, I had to set signal handler for SIGWINCH as 
following sample. 

---
import curses, select, sys, signal, os

rfd, wfd = os.pipe()
os.set_blocking(wfd, False)

def f(*args): pass
signal.signal(signal.SIGWINCH, f)
signal.set_wakeup_fd(wfd)

def main(stdscr):
i=0
while True:
y, x = stdscr.getmaxyx()
stdscr.addstr(i, 0, "%d x:%d y:%d" % (i, x, y))
i+=1
stdscr.refresh()
try:
s=select.select([sys.stdin, rfd], [], [])
except InterruptedError:
stdscr.addstr(i, 0, "%d InterruptedError" % i)
i+=1
continue
try:
c=stdscr.get_wch()
except curses.error:
stdscr.addstr(i, 0, "%d curses.error" % i)
i+=1
continue
if c == 'q':
break

curses.wrapper(main)
-

This code doesn't display updated size of terminal because SIGWINCH signal is 
not sent to nurses library. I have to call curses.resizeterm() manually to tell 
new terminal size to nurses.

I don't know this is common situation or not, but In general, it is not safe to 
set signal handler when the signal is used by third-party library.

--

___
Python tracker 

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



[issue25508] LogRecord attributes are not tuple, when logging only dict

2015-10-29 Thread R. David Murray

R. David Murray added the comment:

I believe this is due to the way % formatting works, and so is a doc bug.  
Vinay will know for sure, of course :)

--
nosy: +r.david.murray, vinay.sajip

___
Python tracker 

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



[issue25510] fileinput.FileInput.readline() always returns str object at the end even if in 'rb' mode

2015-10-29 Thread Ryosuke Ito

Changes by Ryosuke Ito :


--
type:  -> behavior

___
Python tracker 

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



[issue25510] fileinput.FileInput.readline() always returns str object at the end even if in 'rb' mode

2015-10-29 Thread Ryosuke Ito

Changes by Ryosuke Ito :


--
components: +Library (Lib)
versions: +Python 3.5

___
Python tracker 

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



[issue25510] fileinput.FileInput.readline() always returns str object at the end even if in 'rb' mode

2015-10-29 Thread Ryosuke Ito

New submission from Ryosuke Ito:

In Python3, fileinput.FileInput.readline() always returns str object at the end,
even if in 'rb' mode.
Here's a test code.

import fileinput

fi = fileinput.input('test_fileinput.py', mode='rb')

while True:
line = fi.readline()
assert isinstance(line, bytes)
if not len(line):
break

It fails in Python3.2 to 3.5.

I wrote a patch for this.
With it, the test above passes.

--
files: fileinput.py.diff
keywords: patch
messages: 253675
nosy: Ryosuke Ito
priority: normal
severity: normal
status: open
title: fileinput.FileInput.readline() always returns str object at the end even 
if in 'rb' mode
Added file: http://bugs.python.org/file40895/fileinput.py.diff

___
Python tracker 

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



[issue25509] PyImport_ImportModule inaccurately described

2015-10-29 Thread Memeplex

New submission from Memeplex:

The documentation (for 3.5) states that "[PyImport_ImportModule] is a 
simplified interface to PyImport_ImportModuleEx()" but the current 
implementation calls PyImport_Import instead, which is a higher level interface 
that takes into account import hooks. Older versions of PyImport_ImportModule 
(say 2.0) did call PyImport_ImportModuleEx, but that's no longer the case.

The PyImport_Import* naming convention got a bit messy with the years and maybe 
I'm not understanding the intention quite well, but it seems to me that the 
documentation is outdated and that there is a change in semantics for 
PyImport_ImportModule.

--
assignee: docs@python
components: Documentation
messages: 253674
nosy: docs@python, memeplex
priority: normal
severity: normal
status: open
title: PyImport_ImportModule inaccurately described
versions: Python 3.5

___
Python tracker 

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



[issue25508] LogRecord attributes are not tuple, when logging only dict

2015-10-29 Thread Ondrej Sejvl

New submission from Ondrej Sejvl:

Hi,

in doc https://docs.python.org/3.4/library/logging.html#logrecord-attributes 
there is
argsYou shouldn’t need to format this yourself. The tuple of arguments 
merged into msg to produce message.

But when I log message with 1 arg - a dict - in record.args will be this dict

```
import logging

class H(logging.Handler):
def emit(self, record):
print(record.args, type(record.args))

lgr = logging.getLogger()
lgr.addHandler(H())
lgr.error("msg", 1)
lgr.error("msg", dict(a=1))
lgr.error("msg", dict(a=1), 2)
```
output:
```
(1,) 
{'a': 1} 
({'a': 1}, 2) 
```

--
messages: 253673
nosy: sejvlond
priority: normal
severity: normal
status: open
title: LogRecord attributes are not tuple, when logging only dict
versions: Python 2.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



[issue25444] Py Launch Icon

2015-10-29 Thread Nils Lindemann

Nils Lindemann added the comment:

i see now what you mean. I have this icon too (py 3.5.0 idle icon.png). 
Something is misconfigured with the icons in the python 3.5.0 windows 
installer, also python files in explorer have no icons.

Thanks for your hint with the python ideas list, i will post a message there.

--
Added file: http://bugs.python.org/file40894/py 3.5.0 idle icon.png

___
Python tracker 

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



[issue25507] IDLE: user code 'import tkinter; tkinter.font' should fail

2015-10-29 Thread Terry J. Reedy

New submission from Terry J. Reedy:

In python, 'import tkinter; tkinter.font' fails with AttributeError.  In IDLE, 
it does not, which is a bug,  This lead to a Stackoverflow question 'Why does 
my code run in IDLE but not with Python'?

The issue is that importing modules in a package has the side-effect of adding 
the module name to the package namespace.  IDLE's user process runs 
idlelib/run.py.  While *run* does not import tkinter submodules, it imports 
other modules that do, and the net effect is to add colorchooser, commondialog, 
dialog, filedialog, font, messagebox, and simpledialog to the tkinter 
namespace, linked to the corresponding module objects.  None are needed in 
normal operation.

My first thought was to refactor so that the additions, which run does not 
need, are not added.  My second thought seemed simpler.  Delete them (in 
run.py) after the imports.  But it turns out that after deleting a submodule 
attribute re-import does not work right; the name addition only happens when a 
module is created, not when found in the sys.modules cache.

>>> import tkinter; import tkinter.font  # imagine this in run.py
>>> tkinter.font

>>> del tkinter.font  # and this in run also, after all imports
>>> import tkinter.font  # imagine this in user code
>>> tkinter.font  # and then this
Traceback (most recent call last):  # it does not work as it should
  File "", line 1, in 
AttributeError: module 'tkinter' has no attribute 'font'

Scratch that idea, and return to refactoring.  An obvious culprit in run.py is 
the import of PyShell.  This leads to the import of nearly all of idlelib.  
However, there are only 4 shared objects actually used, and I believe they 
could just as well be defined in run (or even in rpc.py or something) and 
imported from run into PyShell.  Then the PyShell import could be deleted.  I 
still need to look at the other imports.

On startup, user sys.modules also has about 50 other (non-idlelib) stdlib 
modules not imported by python itself.  Not importing PyShell in the 2nd 
process should reduce this number and speed up IDLE startup, which takes 
several seconds, first time after boot up, on Windows.  It would be good to 
only import into the user process what is actually needed.

(Initially importing into the idle process only what is needed to start would 
also be good, but a separate issue.)

In 2.7, Tkinter is not a package, so I do not believe it is directly affected 
by this issue.  On the other hand, it also imports too much.  So backporting 
changes to keep things mostly synchronized should benefit 2.7 startup time also.

--
messages: 253671
nosy: markroseman, terry.reedy
priority: normal
severity: normal
stage: needs patch
status: open
title: IDLE: user code 'import tkinter; tkinter.font' should fail
type: behavior
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6

___
Python tracker 

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



[issue24765] Move .idlerc to %APPDATA%\IDLE on Windows

2015-10-29 Thread eryksun

eryksun added the comment:

On Windows, how about creating a junction (_winapi.CreateJunction in 3.5, or 
the shell's mklink /j) from ~\.idlerc to %APPDATA%\idle? If ~\.idlerc already 
exists, it could be moved to %APPDATA%\idle before creating the junction. New 
code would directly use %APPDATA%\idle, but old code would continue to use 
~\.idlerc.

Creating junctions requires no special privilege, but IDLE would need write 
access to the user's home directory. If write access is denied, at least newer 
IDLE versions that use %APPDATA% would work.

On Linux, a symbolic link could be created from ~/.idlerc to 
[$XDG_CONFIG_HOME|~/.config]/idle.

--

___
Python tracker 

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



[issue25156] shutil.copyfile should internally use os.sendfile when possible

2015-10-29 Thread desbma

desbma added the comment:

Thanks for the comment.

> Also, the os.sendfile() doc suggests that some platforms only support writing 
> to sockets, so I definitely think a backup plan is needed.

You are right, the man page clearly says:
> Applications may wish to fall back to read(2)/write(2) in the case
> where sendfile() fails with EINVAL or ENOSYS.

I will improve the code and add tests for conditions where sendfile fails.

I have tested it manually, but I will also add a test with a copy of a file > 
4GB (it causes several calls to sendfile).

--

___
Python tracker 

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



[issue8231] Unable to run IDLE without write-access to home directory

2015-10-29 Thread Terry J. Reedy

Terry J. Reedy added the comment:

OK: call GetUserCfgDir once on creation of idleConf instance and set .userdir 
attribute.  Replace repeated calls in PyShell and Editor with attributes 
accesses.  I tested that, with patch, IDLE starts and rewrites both 
breakpoints.lst and recent-files.lst as appropriate.

--
Added file: http://bugs.python.org/file40893/@cfgdir2.diff

___
Python tracker 

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



[issue24765] Move .idlerc to %APPDATA%\IDLE on Windows

2015-10-29 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I do not consider the presence of .idlec in $HOME on Windows to be a problem in 
itself.  There are numerous applications, unix-derived and otherwise, that do 
the same with config files.  Very few, if any, have the issue of sharing 
between multiple simultaneous versions. Installing a new versions deletes the 
old.  Many do not have the issue of users needing to edit the files.  These 
would be better candidates for making the switch.

Under current circumstances, I reject the proposal.  However, since I hope 
circumstances change, I am closing this as 'postponed' rather than 'rejected'.  
What I hope we can do, to make me *want* to re-open this.

* Switch from almost-dependable sockets to always-dependable pipes and delete 
the backup single-process (-n) mode (see IDLE Help).

* Switch from one user-code execution process to one for each editor window 
(including the shell).

* Let any recent (and installed) python version be chosen for each execution 
process.

* Improve configuration handling to where the need for user editing is mostly 
gone.  Example: ability to add a custom theme from a file without the user copy 
and pasting.

Each of these has benefits in itself, and the net effect would be that most 
everyone would only need to run the latest IDLE they have and not need to touch 
the .cfg files.  At this point, we would want to change the format and put them 
in a different (and less accessible) place anyway.

--
resolution:  -> postponed
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



[issue25505] undefined name 'window' in Tools/scripts/fixdiv.py

2015-10-29 Thread John Mark Vandenberg

Changes by John Mark Vandenberg :


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue25506] test_pprint reuses test_user_dict

2015-10-29 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you John.

--
assignee:  -> serhiy.storchaka
resolution:  -> fixed
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



[issue25506] test_pprint reuses test_user_dict

2015-10-29 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 0e0f3f5195f8 by Serhiy Storchaka in branch '3.5':
Issue25506: Fixed a copy-pasting error in test_pprint.
https://hg.python.org/cpython/rev/0e0f3f5195f8

New changeset 30b6c3bbefc7 by Serhiy Storchaka in branch 'default':
Issue25506: Fixed a copy-pasting error in test_pprint.
https://hg.python.org/cpython/rev/30b6c3bbefc7

--
nosy: +python-dev

___
Python tracker 

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



[issue25498] Python 3.4.3 core dump with simple sample code

2015-10-29 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
assignee:  -> serhiy.storchaka
priority: normal -> high
stage: needs patch -> patch review

___
Python tracker 

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



[issue25506] test_pprint reuses test_user_dict

2015-10-29 Thread John Mark Vandenberg

John Mark Vandenberg added the comment:

Sorry; the first patch includes unrelated fixes.

--
Added file: http://bugs.python.org/file40892/test_pprint-fix.diff

___
Python tracker 

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



[issue25506] test_pprint reuses test_user_dict

2015-10-29 Thread John Mark Vandenberg

New submission from John Mark Vandenberg:

test_pprint defined test_user_dict twice, once for UserDict, and the second for 
UserList.

--
components: Library (Lib), Tests
files: test_pprint-fix.diff
keywords: patch
messages: 253663
nosy: John.Mark.Vandenberg, serhiy.storchaka
priority: normal
severity: normal
status: open
title: test_pprint reuses test_user_dict
type: behavior
versions: Python 3.5, Python 3.6
Added file: http://bugs.python.org/file40891/test_pprint-fix.diff

___
Python tracker 

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



[issue25498] Python 3.4.3 core dump with simple sample code

2015-10-29 Thread eryksun

Changes by eryksun :


Added file: http://bugs.python.org/file40890/ctypes_from_buffer_2.patch

___
Python tracker 

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



[issue13828] Further improve casefold documentation

2015-10-29 Thread Mark Summerfield

Mark Summerfield added the comment:

I think the str.casefold() docs are fine as far as they go, rightly covering 
what it _does_ rather than _how_, yet providing a reference for the details. 
But what they lack is more complete information. For example I discovered this:

>>> x = "files and shuffles"
>>> x
'files and shuffles'
>>> x.casefold()
'files and shuffles'

In view of this I would add one sentence:

In addition to lowercasing, this function also expands ligatures, for 
example, "fi" becomes "fi".

--
nosy: +mark

___
Python tracker 

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