[issue25911] Regression: os.walk now using os.scandir() breaks bytes filenames on windows

2016-03-24 Thread Roundup Robot

Roundup Robot added the comment:

New changeset d54ee39b061f by Victor Stinner in branch 'default':
Fix DeprecationWarning on Windows
https://hg.python.org/cpython/rev/d54ee39b061f

--

___
Python tracker 

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



[issue26633] multiprocessing behavior combining daemon with non-daemon children inconsistent with threading

2016-03-24 Thread SilentGhost

Changes by SilentGhost :


--
nosy: +jnoller, sbt

___
Python tracker 

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



[issue26076] redundant checks in tok_get in Parser\tokenizer.c

2016-03-24 Thread SilentGhost

SilentGhost added the comment:

Could any one of the core developers have a look? Seems like a rather 
straightforward change.

--

___
Python tracker 

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



[issue25911] Regression: os.walk now using os.scandir() breaks bytes filenames on windows

2016-03-24 Thread Roundup Robot

Roundup Robot added the comment:

New changeset eb91d0387d59 by Victor Stinner in branch 'default':
Enhance os._DummyDirEntry
https://hg.python.org/cpython/rev/eb91d0387d59

--

___
Python tracker 

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



[issue25911] Regression: os.walk now using os.scandir() breaks bytes filenames on windows

2016-03-24 Thread STINNER Victor

STINNER Victor added the comment:

I faile to reproduce the bug by running test_os alone on Windows 8.

I wrote a script to try to isolate a sequential list of tests which reproduce 
the bug on Windows, but I failed to find such list after 2 hours:
https://bitbucket.org/haypo/misc/src/3e2e6138798c6cec061544ff116e50a8d1d6d2b8/python/isolate.py?fileviewer=file-view-default

So I'm unable to reproduce the bug, I tried a change to enhance 
os._DummyDirEntry, it should now mimick better the C implementation of 
os.DirEntry. Let's see if the test still fails randomly...

--

___
Python tracker 

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



[issue23551] IDLE to provide menu link to PIP gui.

2016-03-24 Thread Eric Khoo Jiun Hooi

Eric Khoo Jiun Hooi added the comment:

Thank @Terry for your suggestion. I have been working on this few hour to fix 
and improve the code. I have also add some new feature into the application. 
Hope you can help me to review it again. Thank.

About the proposal, please help me to review it if you have free time.

--
Added file: http://bugs.python.org/file42269/pip_gui_v2.py

___
Python tracker 

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



[issue23551] IDLE to provide menu link to PIP gui.

2016-03-24 Thread Eric Khoo Jiun Hooi

Changes by Eric Khoo Jiun Hooi :


Added file: http://bugs.python.org/file42270/GSoC2016Proposal(1).pdf

___
Python tracker 

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



[issue23551] IDLE to provide menu link to PIP gui.

2016-03-24 Thread Eric Khoo Jiun Hooi

Eric Khoo Jiun Hooi added the comment:

I also change some of the design like instead of showing the installed package 
information beside the list, I think that it will be better to show the package 
information on a new pop up window. You can try to double click the list of 
search tab and installed package tab. It is functional now.

--

___
Python tracker 

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



[issue26614] False/0 and True/1 collision when used as dict keys?

2016-03-24 Thread Mark Dickinson

Mark Dickinson added the comment:

"Apparently True and 1 hash to the same item and False and 0 hash to the same 
item"

Just to clear up a possible misconception here, the key point here is not that 
they hash to the same integer, but that they're *equal*:

>>> True == 1
True
>>> False == 0
True

In contrast, here are two elements whose hash is equal but which serve as 
distinct keys:

>>> hash(-1) == hash(-2)
True
>>> len({-1: -1, -2: -2})
2

IOW, dictionary semantics are defined in terms of equality, not hashing. The 
hashing part should really be thought of as just a (somewhat exposed) 
implementation detail.

--
nosy: +mark.dickinson

___
Python tracker 

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



[issue26635] Python default date does not match Unix time

2016-03-24 Thread Itay Grudev

New submission from Itay Grudev:

When parsing a time only string like:

```
datetime.datetime.strptime('13:48:25', '%H:%M:%S')
```

This produces:

```
datetime.datetime(1900, 1, 1, 13, 48, 25)
```

Not that the year is `1900` which just doesn't make sense. This will produce 
`-1` when you attempt to get it's UNIX timestamp. And while that sounds weird 
it is very useful.

The default year should be 1970. And this will resolve the issue.

--
messages: 262337
nosy: Itay Grudev
priority: normal
severity: normal
status: open
title: Python default date does not match Unix time
type: behavior

___
Python tracker 

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



[issue26614] False/0 and True/1 collision when used as dict keys?

2016-03-24 Thread STINNER Victor

STINNER Victor added the comment:

Many values have the same hash value, it's not an issue. The hash is only a 
best effort function to reduce hash collision, but hash collision is well 
handled in the dict type (as explained in other messages).

>>> hash(1) == hash(1.0) == hash(1.0+0j) == 1
True
>>> hash('') == hash(b'') == hash(0) == hash(0.0) == hash(0.0j) == 0
True

--
nosy: +haypo

___
Python tracker 

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



[issue26635] Python default date does not match Unix time

2016-03-24 Thread STINNER Victor

STINNER Victor added the comment:

The year 1900 is a delibrate choice, it's even documented:
https://docs.python.org/dev/library/datetime.html#strftime-and-strptime-behavior

"For time objects, the format codes for year, month, and day should not be 
used, as time objects have no such values. If they’re used anyway, 1900 is 
substituted for the year, and 1 for the month and day."

> The default year should be 

If you expect a year, you can easily use dt.replace(year=), no?

Or start with a datetime.time object and then build a datetime.datetime using 
the time? It's up to you.

We will not change a default value, it will break the backward compatibility.

--
nosy: +belopolsky, haypo
resolution:  -> not a bug
status: open -> closed

___
Python tracker 

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



[issue26620] Fix ResourceWarning warnings in test_urllib2_localnet

2016-03-24 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 54d7e9919876 by Victor Stinner in branch 'default':
Closes #26620: Fix ResourceWarning in test_urllib2_localnet
https://hg.python.org/cpython/rev/54d7e9919876

--
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



[issue26620] Fix ResourceWarning warnings in test_urllib2_localnet

2016-03-24 Thread STINNER Victor

STINNER Victor added the comment:

Martin wrote:
> This patch looks okay to me. I left one review suggestion.

Thanks for the review, I changed this code.

While testing one more time my patch with CTRL+c, I noticed that sometimes the 
servers are not stopped properly and os.environ is not restored.

I made some extra changes to try to restore os.environ and try to close the 
server in more cases.

It's not perfect. Since unittest.TestCase.doCleanups() doesn't handle 
KeyboardInterrupt, there is no warranty that cleanup functions are always 
executed.

> Focussing on test_sending_headers(), the ResourceWarning seems to be only 
> shown since revision 46329eec5515 (Issue 26590). In simpler cases, the 
> warning would be bypassed due to Issue 19829. But in this cases it seems 
> there is a garbage cycle which may be involved in the new warning.

It's possible that Python 3.5 failed to log ResourceWarning in some cases, 
Python 3.6 should be better on this part.

--

___
Python tracker 

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



[issue23551] IDLE to provide menu link to PIP gui.

2016-03-24 Thread Steve Dower

Changes by Steve Dower :


--
nosy:  -steve.dower

___
Python tracker 

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



[issue26628] Undefined behavior calling C functions with ctypes.Union arguments

2016-03-24 Thread Thomas

Thomas added the comment:

So after some more pondering about the issue I read the documentation again:

> Warning ctypes does not support passing unions or structures with bit-fields 
> to functions by value.

Previously I always read this as 'does not support passing unions with 
bit-fields'... I guess it is meant otherwise. IMHO this should be formulated 
more clearly, like: "does not support passing structures with bit-fields or 
unions to functions by value.".

Also I would strongly argue to generally prohibit this with an exception 
instead of just trying if libffi maybe handles this on the current 
architecture. libffi clearly does not support unions. This just introduces 
subtle bugs.

See also: https://github.com/atgreen/libffi/issues/33

--
title: Segfault in cffi with ctypes.union argument -> Undefined behavior 
calling C functions with ctypes.Union arguments

___
Python tracker 

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



[issue23551] IDLE to provide menu link to PIP gui.

2016-03-24 Thread Terry J. Reedy

Terry J. Reedy added the comment:

After running the code, I want to stick with details in the same window.  The 
tab should be a Frame with a PanedWindow on top with list frame on left and 
detail frame on right.  The buttons would be under the paned window.  Run 
Lib/turtledemo/__main__.py either from IDLE or with 'python -m turtledemo' to 
see an example.

Eric: make sure you read my response to Upendra on core-mentorship list: 
"Inquiry about the "PIP GUI Project".

Raymond and Donald: I am seriously considering mentoring this as a GSOC project 
next summer.  Can I count on at least one of you occasionally reviewing the 
design and functioning of interim submissions (by running the code and clicking 
around)?

--

___
Python tracker 

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



[issue19829] _pyio.BufferedReader and _pyio.TextIOWrapper destructor don't emit ResourceWarning if the file is not closed

2016-03-24 Thread STINNER Victor

STINNER Victor added the comment:

Attached patch modifies _pyio to mimick better the reference io module:

* Add IOBase._finalizing
* IOBase.__del__() sets _finalizing to True
* Add FileIO._dealloc_warn()
* Remove FileIO.__del__()
* FileIO.close(), _BufferedIOMixin.close() and TextIOWrapper.close() now calls 
_dealloc_warn() if _finalizing is true
* Override closed() method in FileIO: needed because FileIO.close() now calls 
super().close() before logging the ResourceWarning, and the file is expected to 
see open in the warning
* FileIO.close() now calls super().close() *before* closing the file descriptor

I added hasattr(.., '_dealloc_warn') sanity checks because _dealloc_warn() are 
added to concrete classes, not to base classes.

--
Added file: http://bugs.python.org/file42271/pyio_res_warn.patch

___
Python tracker 

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



[issue19829] _pyio.BufferedReader and _pyio.TextIOWrapper destructor don't emit ResourceWarning if the file is not closed

2016-03-24 Thread STINNER Victor

Changes by STINNER Victor :


Removed file: http://bugs.python.org/file42271/pyio_res_warn.patch

___
Python tracker 

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



[issue19829] _pyio.BufferedReader and _pyio.TextIOWrapper destructor don't emit ResourceWarning if the file is not closed

2016-03-24 Thread STINNER Victor

STINNER Victor added the comment:

(oops, there was a typo in my first patch)

--
Added file: http://bugs.python.org/file42272/pyio_res_warn-2.patch

___
Python tracker 

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



[issue26632] __all__ decorator

2016-03-24 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

On Mar 24, 2016, at 02:48 AM, Ethan Furman wrote:

>On the down side, you know somebody is going to @public a class' method --
>how do we check for that?

Do we need to?  Consenting adults and __all__.

OT1H, you do get an AttributeError if you from-import-* and there are things
in __all__ that aren't in the module.  OTOH, it's a pretty obvious error.

--

___
Python tracker 

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



[issue26636] SystemError while running tests: extra exception raised

2016-03-24 Thread Denis

New submission from Denis:

Looks like related to Issue23571
Probably same issue as in Django, but in other Python module.

While compiling python-module-crypto:

= 
ERROR: test_getStrongPrime_randfunc_bogus 
(Crypto.SelfTest.Util.test_number.FastmathTests) 
Test that when getStrongPrime is called, an exception is raised if randfunc 
returns something bogus. 
-- 
TypeError: randfunc must return a string of random bytes 

During handling of the above exception, another exception occurred: 

SystemError: PyEval_EvalFrameEx returned a result with an error set 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
 File "build/lib.linux-i686-3.5/Crypto/SelfTest/Util/test_number.py", line 322, 
in test_getStrongPrime_randfunc_bogus 
   self.assertRaises(TypeError, number._fastmath.getStrongPrime, 512, 
randfunc=randfunc) 
 File "/usr/lib/python3.5/unittest/case.py", line 765, in assertRaises 
   return context.handle('assertRaises', args, kwargs) 
 File "/usr/lib/python3.5/unittest/case.py", line 214, in handle 
   callable_obj(*args, **kwargs) 
SystemError: PyEval_EvalFrameEx returned a result with an error set 

== 
ERROR: test_getStrongPrime_randfunc_exception 
(Crypto.SelfTest.Util.test_number.FastmathTests) 
Test that when getStrongPrime is called, an exception raised in randfunc is 
propagated. 
-- 
Crypto.SelfTest.Util.test_number.MyError 

During handling of the above exception, another exception occurred: 

SystemError:  returned a 
result with an error set 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
 File "build/lib.linux-i686-3.5/Crypto/SelfTest/Util/test_number.py", line 308, 
in test_getStrongPrime_randfunc_exception 
   self.assertRaises(MyError, number._fastmath.getStrongPrime, 512, 
randfunc=randfunc) 
 File "/usr/lib/python3.5/unittest/case.py", line 765, in assertRaises 
   return context.handle('assertRaises', args, kwargs) 
 File "/usr/lib/python3.5/unittest/case.py", line 214, in handle 
   callable_obj(*args, **kwargs) 
 File "build/lib.linux-i686-3.5/Crypto/SelfTest/Util/test_number.py", line 307, 
in randfunc 
   raise MyError 
SystemError:  returned a 
result with an error set 

The file that cause that exception can be found at

http://git.altlinux.org/gears/p/python-module-pycrypto.git?p=python-module-pycrypto.git;a=blob;f=lib/Crypto/SelfTest/Util/test_number.py;h=ac23e917b6e7d982a33fff0a14bec3e769500ba0;hb=86c4aa4683cd89f89c3d01a689efa525f961d340

--
components: Interpreter Core
messages: 262349
nosy: nbr_alt
priority: normal
severity: normal
status: open
title: SystemError while running tests: extra exception raised
type: behavior
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



[issue19829] _pyio.BufferedReader and _pyio.TextIOWrapper destructor don't emit ResourceWarning if the file is not closed

2016-03-24 Thread STINNER Victor

STINNER Victor added the comment:

Oh, the io module is more complex than what I expected :-) test_io fails with 
pyio_res_warn-2.patch.

test_io now pass with pyio_res_warn-3.patch. I fixed FileIO.close() to always 
call super().close(), and set self._fd to -1 even if logging the 
ResourceWarning raised an exception.

--
Added file: http://bugs.python.org/file42273/pyio_res_warn-3.patch

___
Python tracker 

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



[issue26636] SystemError while running tests: extra exception raised

2016-03-24 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +haypo

___
Python tracker 

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



[issue19829] _pyio.BufferedReader and _pyio.TextIOWrapper destructor don't emit ResourceWarning if the file is not closed

2016-03-24 Thread STINNER Victor

STINNER Victor added the comment:

del-detach.patch: I don't understand the change in _pyio.py. I think that the 
change on socket.py is no more need since the change 46329eec5515 (issue 
#26590).

del-flush.patch:
* change on IOBase.__del__() change the behaviour compared to the io module, I 
don't think that it's correct. I may also break backward compatibility :-/
* change on fileio.c implements a finalizer for FileIO: io.IOBase already 
implements a finalizer which calls close(), I'm not sure that this change is 
needed?
* change on iobase.c removes io.IOBase finalizer. I don't understand this. It 
breaks ResourceWarning on io.Buffered* and io.TextIOWrapper classes, no?

Well, I guess that these two patches were written before Serhiy reimplemented 
the FileIO in pure Python, and this change outdated your two patches.

--

___
Python tracker 

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



[issue19829] _pyio.BufferedReader and _pyio.TextIOWrapper destructor don't emit ResourceWarning if the file is not closed

2016-03-24 Thread STINNER Victor

STINNER Victor added the comment:

Try attached res_warn.py script to test manually all ResourceWarning warnings.

Ouput of python3.6 -Wd res_warn.py:
--
text
<_pyio.TextIOWrapper name='/etc/issue' mode='r' encoding='UTF-8'>
res_warn.py:9: ResourceWarning: unclosed file <_pyio.FileIO name='/etc/issue' 
mode='rb' closefd=True>
  f = None

buffered
<_pyio.BufferedReader name='/etc/issue'>
res_warn.py:15: ResourceWarning: unclosed file <_pyio.FileIO name='/etc/issue' 
mode='rb' closefd=True>
  f=None

raw
<_pyio.FileIO name='/etc/issue' mode='rb' closefd=True>
res_warn.py:21: ResourceWarning: unclosed file <_pyio.FileIO name='/etc/issue' 
mode='rb' closefd=True>
  f=None

fileio
<_pyio.FileIO name='/etc/issue' mode='rb' closefd=True>
res_warn.py:27: ResourceWarning: unclosed file <_pyio.FileIO name='/etc/issue' 
mode='rb' closefd=True>
  f=None

--


Ouput of python3.6 -X tracemalloc=2 -Wd res_warn.py:
--
text
<_pyio.TextIOWrapper name='/etc/issue' mode='r' encoding='UTF-8'>
res_warn.py:9: ResourceWarning: unclosed file <_pyio.FileIO name='/etc/issue' 
mode='rb' closefd=True>
  f = None
Object allocated at (most recent call first):
  File "/home/haypo/prog/python/default/Lib/_pyio.py", lineno 209
closefd, opener=opener)
  File "res_warn.py", lineno 7
f = _pyio.open(fn, "r")

buffered
<_pyio.BufferedReader name='/etc/issue'>
res_warn.py:15: ResourceWarning: unclosed file <_pyio.FileIO name='/etc/issue' 
mode='rb' closefd=True>
  f=None
Object allocated at (most recent call first):
  File "/home/haypo/prog/python/default/Lib/_pyio.py", lineno 209
closefd, opener=opener)
  File "res_warn.py", lineno 13
f = _pyio.open(fn, "rb")

raw
<_pyio.FileIO name='/etc/issue' mode='rb' closefd=True>
res_warn.py:21: ResourceWarning: unclosed file <_pyio.FileIO name='/etc/issue' 
mode='rb' closefd=True>
  f=None
Object allocated at (most recent call first):
  File "/home/haypo/prog/python/default/Lib/_pyio.py", lineno 209
closefd, opener=opener)
  File "res_warn.py", lineno 19
f = _pyio.open(fn, "rb", 0)

fileio
<_pyio.FileIO name='/etc/issue' mode='rb' closefd=True>
res_warn.py:27: ResourceWarning: unclosed file <_pyio.FileIO name='/etc/issue' 
mode='rb' closefd=True>
  f=None
Object allocated at (most recent call first):
  File "res_warn.py", lineno 25
f = _pyio.FileIO(fn, "rb")

--

--
Added file: http://bugs.python.org/file42274/res_warn.py

___
Python tracker 

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



[issue19829] _pyio.BufferedReader and _pyio.TextIOWrapper destructor don't emit ResourceWarning if the file is not closed

2016-03-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I don't like _dealloc_warn() at all. It looks as a dirty hack and doesn't work 
with custom file-like objects.

I think we should use one of Martin's option. If there are any issues with 
garbage collecting, we should fix the garbage collector.

--
versions: +Python 3.5, Python 3.6 -Python 3.3, Python 3.4

___
Python tracker 

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



[issue26637] importlib: better error message when import fail during Python shutdown

2016-03-24 Thread STINNER Victor

New submission from STINNER Victor:

Example of script.py:
-
class Bla:
def __del__(self):
try:
import 
except Exception as exc:
print("import error: [%s] %r" % (type(exc), exc))

bla = Bla()
-

Running this example logs a strange error:
-
$ python3.5 script.py
import error: [] TypeError("'NoneType' object is not 
iterable",)
-

The error comes from importlib._bootstrap._find_spec() which tries to iterator 
on sys.meta_path, whereas PyImport_Cleanup() was called and this function 
setted sys.meta_path to None.

Attached patch enhances _find_spec() to handle this case to return None. Error 
with the patch:
-
$ python3.5 script.py
import error: [] ImportError('sys.meta_path is None, 
Python is likely shutting down',)
-

--
components: Library (Lib)
files: importlib_shutdown.patch
keywords: patch
messages: 262352
nosy: brett.cannon, eric.snow, haypo
priority: normal
severity: normal
status: open
title: importlib: better error message when import fail during Python shutdown
versions: Python 2.7, Python 3.5, Python 3.6
Added file: http://bugs.python.org/file42275/importlib_shutdown.patch

___
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

2016-03-24 Thread A. Jesse Jiryu Davis

Changes by A. Jesse Jiryu Davis :


--
nosy: +emptysquare

___
Python tracker 

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



[issue21925] ResourceWarning sometimes doesn't display

2016-03-24 Thread STINNER Victor

STINNER Victor added the comment:

It looks like the warnings is logged when the C implemention is used. When the 
Python implementation is used, "import linecache" or "linecache.getline()" 
fail, and so the warnings is skipped.

Attached patch makes the Python implementation safer when Python is shutting 
down. Add "try/except Exception" to ignore exceptions on import, linecache and 
tracemalloc.

--
Added file: http://bugs.python.org/file42276/warnings_shutdown.patch

___
Python tracker 

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



[issue25654] test_multiprocessing_spawn ResourceWarning with -Werror

2016-03-24 Thread STINNER Victor

Changes by STINNER Victor :


--
nosy: +haypo

___
Python tracker 

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



[issue22898] segfault during shutdown attempting to log ResourceWarning

2016-03-24 Thread STINNER Victor

STINNER Victor added the comment:

I tried the following script on Python 3.5 and Python 3.6 and I failed to 
reproduce the bug:
---
import sys, traceback

class MyException(Exception):
def __init__(self, *args):
1/0

def gen():
f = open(__file__, mode='rb', buffering=0)
yield

g = gen()
next(g)
recursionlimit = sys.getrecursionlimit()
sys.setrecursionlimit(len(traceback.extract_stack())+3)
try:
g.throw(MyException)
finally:
sys.setrecursionlimit(recursionlimit)
print('Done.')
---

Note: I had to add "+3" to the sys.setrecursionlimit() call, otherwise the 
limit is too low and you get a RecursionError (it's a recent bugfix, issue 
#25274).

Can somone else please confirm that the bug is fixed?

--

___
Python tracker 

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



[issue10305] Cleanup up ResourceWarnings in multiprocessing

2016-03-24 Thread STINNER Victor

STINNER Victor added the comment:

Sorry but without any information about the module or function which emits such 
ResourceWarning, I prefer to close the issue.

Anyway, with Python 3.6, it became trivial to identify the root cause of 
ResourceWarning warinings:
https://docs.python.org/dev/whatsnew/3.6.html#warnings

So it should now be much easier to fix them.

--
nosy: +haypo
resolution:  -> out of date
status: open -> closed

___
Python tracker 

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



[issue21925] ResourceWarning sometimes doesn't display

2016-03-24 Thread STINNER Victor

STINNER Victor added the comment:

See also the issue #26637: "importlib: better error message when import fail 
during Python shutdown".

--

___
Python tracker 

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



[issue25654] test_multiprocessing_spawn ResourceWarning with -Werror

2016-03-24 Thread STINNER Victor

STINNER Victor added the comment:

I marked the issue #10305 as a duplicate of this issue.

--

___
Python tracker 

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



[issue26636] SystemError while running tests: extra exception raised

2016-03-24 Thread STINNER Victor

STINNER Victor added the comment:

> Probably same issue as in Django, but in other Python module.

Do you understand that bug very likely comes from your code?

Please review the code of the Crypto module (especially 
number._fastmath.getStrongPrime) to ensure that it doesn't return a result with 
an exception set.

If a function raises an exception, it must returns NULL.

--

___
Python tracker 

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



[issue26624] Windows hangs in call to CRT setlocale()

2016-03-24 Thread STINNER Victor

STINNER Victor added the comment:

> I'll email the CRT team and see what they know about this.

Thanks. It helps to have a Microsoft employee working on CPython :-)

--

___
Python tracker 

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



[issue19829] _pyio.BufferedReader and _pyio.TextIOWrapper destructor don't emit ResourceWarning if the file is not closed

2016-03-24 Thread STINNER Victor

STINNER Victor added the comment:

> I don't like _dealloc_warn() at all. It looks as a dirty hack and doesn't 
> work with custom file-like objects.

I tried to support emitting a ResourceWarning when the close() method is 
overriden in a subclass, but then I saw that io doesn't support this use case 
neither:
---
import io
import os

class MyFile(io.FileIO):
def close(self):
os.close(self.fileno())

f = MyFile('/etc/issue')
f = None
---
=> no warning

Ok, now I have to read again Martin's patches since I didn't understand them at 
the first read :-)

--

___
Python tracker 

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



[issue10305] Cleanup up ResourceWarnings in multiprocessing

2016-03-24 Thread STINNER Victor

STINNER Victor added the comment:

Oh, I found the issue #25654 which contains more information and even patches.

--
superseder:  -> test_multiprocessing_spawn ResourceWarning with -Werror

___
Python tracker 

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



[issue26624] Windows hangs in call to CRT setlocale()

2016-03-24 Thread Steve Dower

Steve Dower added the comment:

If the comment is in the sources, presumably it's also handled correctly. But 
it does seem like there's potential here for simultaneous thread creation and 
first-time calls into OS locale functions to cause a deadlock.

I'll email the CRT team and see what they know about this.

--

___
Python tracker 

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



[issue23551] IDLE to provide menu link to PIP gui.

2016-03-24 Thread Eric Khoo Jiun Hooi

Eric Khoo Jiun Hooi added the comment:

The implementation of features that already provided by command line interface 
should not be a problem. However, I do not understand how the search for 
package and change default repository function. Is it going to search the 
package from other website? Terry, is the pip_test.py need urgently? Because I 
am not familiar with the unittest library and it required me a few days to read 
its documentation. Maybe I can write one after the submission of proposal. But 
my first priority now is to change the design of the pip_gui.py file.

--

___
Python tracker 

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



[issue26624] Windows hangs in call to CRT setlocale()

2016-03-24 Thread Steve Dower

Steve Dower added the comment:

It's been fixed, just figuring out when the update will be available, or how to 
get it if it already is.

Jeremy - how up to date is your build machine? It's likely this fix will come 
through Windows Update for most users, but since you're running debug builds I 
think you'll need the latest Visual Studio updates to get it.

--

___
Python tracker 

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



[issue22401] argparse: 'resolve' conflict handler damages the actions of the parent parser

2016-03-24 Thread Jared Deckard

Jared Deckard added the comment:

Adding back components and version data I unintentionally removed in 
http://bugs.python.org/msg262314

--
components: +Documentation, Tests
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



[issue22401] argparse: 'resolve' conflict handler damages the actions of the parent parser

2016-03-24 Thread Jared Deckard

Jared Deckard added the comment:

That is correct. (Thank you for whipping up a repro script from my description).

I appreciate the work around, but it is nearly as verbose as manually 
duplicating the parameters on the child and I would have to type up a large 
comment block to educate future developers on the hack.

Is there some documentation I am missing or is the "resolve" conflict handler 
broken?

> The parents= argument takes a list of ArgumentParser objects, collects all 
> the positional and optional actions from them, and adds these actions to the 
> ArgumentParser object being constructed.
https://docs.python.org/3.6/library/argparse.html#parents

It would be nice if the "error" conflict handler ignored conflicts when the 
actions are identical.

It should be expected that the "resolve" conflict handler would not modify the 
parents. It is exhibiting undocumented and undesirable side effect, which 
indicates to me that it is a bug not a missing feature.

As for the patch, I'm not sure why you would ever want "action_copy" to be 
False. It seems like creating copies to insulate the originals ignores the 
underlying issue that these parents are being mutated when the operation 
implies a union of properties with no side effects.

I don't think the fix for this should be behind an optional flag, I think the 
fix is to update "resolve" to take into consideration multiple parents like the 
custom conflict handler in your sample.

--

___
Python tracker 

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



[issue26637] importlib: better error message when import fail during Python shutdown

2016-03-24 Thread STINNER Victor

STINNER Victor added the comment:

Updated patch with a dot in the comment :-)

Is ImportError the best exception in this case?

--
Added file: http://bugs.python.org/file42277/importlib_shutdown-2.patch

___
Python tracker 

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



[issue26637] importlib: better error message when import fail during Python shutdown

2016-03-24 Thread Brett Cannon

Brett Cannon added the comment:

Either ImportError or TypeError. ImportError makes sense since this is directly 
related to import semantics while TypeError makes sense as we are saying None 
specifically is not allowed.

--

___
Python tracker 

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



[issue23551] IDLE to provide menu link to PIP gui.

2016-03-24 Thread Upendra Kumar

Upendra Kumar added the comment:

Here, I have one doubt regarding the get_data function that should the get_data 
function be a common function for different features for example : 

def _get_data(self, func_option):
"""
A separate function for extracting data from the runpip() function.
It is done in order to get this function tested using unittest module

According to func_option, it returns the data extracted :

Options:
---
1. list : for listing all currently installed packages
2. show  : show details of installed packages
3. search  : show formated search results
4. install  : get results while installing packages
"""

splitted_options = func_option.split()

if splitted_options[0] == 'list':
return runpip(func_option)

elif splitted_options[0] == 'show':
return runpip(func_option)

elif splitted_options[0] == 'search':
return runpip(func_option)

elif splitted_options[0] == 'install':
return runpip(func_option)

I am not clear would this single function for retrieving data would be good for 
uniitest or different functions would be good for retrieving data.

--

___
Python tracker 

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



[issue25951] SSLSocket.sendall() does not return None on success like socket.sendall()

2016-03-24 Thread Aviv Palivoda

Aviv Palivoda added the comment:

Changed SSLSocket.sendall() to return None. Also added a check of the return 
value of the SSLSocket.send(), SSLSocket.sendall() in the tests.

--
keywords: +patch
nosy: +palaviv
Added file: http://bugs.python.org/file42278/25951.patch

___
Python tracker 

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



[issue25609] Add a ContextManager ABC and type

2016-03-24 Thread Brett Cannon

Brett Cannon added the comment:

Here is an updated patch implementing Nick's suggestions and is ready for 3.6 
sans a What's New entry.

As for Python 3.5, I think I will copy __subclasshook__() from 
contextlib.AbstractContextManager and put it in typing.ContextManager so the 
isinstance() checks will work with the type structurally.

LMK if this all sounds/looks reasonable.

--
Added file: http://bugs.python.org/file42279/contextmanagertype.diff

___
Python tracker 

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



[issue22898] segfault during shutdown attempting to log ResourceWarning

2016-03-24 Thread Xavier de Gaye

Xavier de Gaye added the comment:

When tested with runtimerror_singleton_3.py (see msg 231933 above), the latest 
Python 3.6.0a0 (default:3eec7bcc14a4, Mar 24 2016, 20:16:19) still crashes:

$ python runtimerror_singleton_3.py
Importing mymodule.
Traceback (most recent call last):
  File "runtimerror_singleton_3.py", line 26, in 
foo()
  File "runtimerror_singleton_3.py", line 23, in foo
g.throw(MyException)# Entering PyErr_NormalizeException()
  File "runtimerror_singleton_3.py", line 14, in gen
yield
RecursionError: maximum recursion depth exceeded
Segmentation fault (core dumped)

--

___
Python tracker 

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



[issue23551] IDLE to provide menu link to PIP gui.

2016-03-24 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Answering Eric:

'change default repository' would set a value that pip_gui would pass to 
subsequent install requests with the --index-url option.  On Windows, 
http://www.lfd.uci.edu/~gohlke/pythonlibs/ is essential and should be 
pre-listed as an option to select.

'search' (for package on pypi) is a pip command.  Try "pip search xyz".  On 
Windows, I would also want to be able to search the url above.

In the email, I said pip-test.py 'after applications'.

--

___
Python tracker 

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



[issue22401] argparse: 'resolve' conflict handler damages the actions of the parent parser

2016-03-24 Thread paul j3

paul j3 added the comment:

Neither 'parents' or 'resolve' are documented in any detail.  Most of what I 
know comes from reading the code.

'parents' are, I think, most useful when importing a parser from some other 
module.  It lets you add arguments to your own parser without digging into the 
other module's code.  And 'resolve' lets you overwrite arguments.  

Copying arguments by reference is the easiest thing to do in Python, and 
apparently no one asked, 'what if the user wants to use the parent 
independently?'

Note I had to add a 'copy' method, because nothing else in 'argparse' needs it. 
 And no one has written code to check whether two Actions are the same (other 
than the obvious one of checking object ids).  Again, no need.

Copy and paste and utility functions are great ways of defining multiple 
arguments when mechanisms like 'parents' prove to be too clumsy.  Look at 
`test_argparse.py` for examples of utility code that streamlines parser 
definition.  Each test case requires a new parser (or more).

--

___
Python tracker 

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



[issue26637] importlib: better error message when import fail during Python shutdown

2016-03-24 Thread STINNER Victor

STINNER Victor added the comment:

I will reply to my own question: in fact, ImportError is more convenient. The 
"try/except ImportError" pattern is common, in some cases, it's acceptable to 
skip a whole module. For a direct example on import during Python shutdown, see 
the issue #21925: "ResourceWarning sometimes doesn't display" which adds 
"try/except ImportError" to be able to log warnings.

@Brett, Eric: So, do you like importlib_shutdown-2.patch?

--

___
Python tracker 

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



[issue26637] importlib: better error message when import fail during Python shutdown

2016-03-24 Thread STINNER Victor

STINNER Victor added the comment:

Oh. And is it ok to apply this change to Python 2.7 and 3.5?

--

___
Python tracker 

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



[issue23551] IDLE to provide menu link to PIP gui.

2016-03-24 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

You may want to take a look a PyCharm's preferences dialog for inspiration.  I 
am attaching a screenshot.  I like the way they show installed and the latest 
available versions.

--
nosy: +belopolsky
Added file: http://bugs.python.org/file42280/PyCharm packages preferences.png

___
Python tracker 

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



[issue26637] importlib: better error message when import fail during Python shutdown

2016-03-24 Thread Brett Cannon

Brett Cannon added the comment:

It's technically a change in semantics as it shifts what exception is raised, 
so I wouldn't backport it.

--

___
Python tracker 

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



[issue26637] importlib: better error message when import fail during Python shutdown

2016-03-24 Thread STINNER Victor

STINNER Victor added the comment:

> It's technically a change in semantics as it shifts what exception is raised, 
> so I wouldn't backport it.

Ok, I'm fine with only changing Python 3.6.

--

___
Python tracker 

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



[issue26632] __all__ decorator

2016-03-24 Thread Martin Panter

Martin Panter added the comment:

FWIW I already invented this :) as written in Issue 22247. Although I think I 
only used it once or twice in my own personal librarie(s). So it’s a nice sign 
that we came up with the same @public name and usage.

I’m not a fan of hacks depending on the calling frame, and I prefer APIs that 
“only do one thing”. So I am okay with accepting an object and work off its 
__name__ and __module__, but not okay with also accepting a string and guessing 
what module it was defined in.

--
nosy: +martin.panter

___
Python tracker 

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



[issue26624] Windows hangs in call to CRT setlocale()

2016-03-24 Thread Jeremy Kloth

Jeremy Kloth added the comment:

The lastest set of updates were installed on 1/28.  Visual Studio does have 
Update 1.  I'm doing another round of updates now, although nothing related to 
VC 2015 or Visual Studio, however.

--

___
Python tracker 

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



[issue8557] subprocess PATH semantics and portability

2016-03-24 Thread Anthony Sottile

Anthony Sottile added the comment:

Here's the workaround I'm opting for:

if sys.platform =='win32':
distutils.spawn.find_executable(cmd[0]) + cmd[1:]

--
nosy: +Anthony Sottile

___
Python tracker 

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



[issue26632] __all__ decorator

2016-03-24 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

On Mar 24, 2016, at 10:31 PM, Martin Panter wrote:

>FWIW I already invented this :) as written in Issue 22247. Although I think I
>only used it once or twice in my own personal librarie(s). So it’s a nice
>sign that we came up with the same @public name and usage.

Cool!  Consider that bikeshed painted then. :)

>I’m not a fan of hacks depending on the calling frame, and I prefer APIs that
>“only do one thing”. So I am okay with accepting an object and work off its
>__name__ and __module__, but not okay with also accepting a string and
>guessing what module it was defined in.

Yes, but it makes it less convenient to add non-"APIs" to __all__, although I
guess you can just append it at the point of use:

__all__.append('CONST1')
CONST1 = 3

Not as pretty, and now you have two ways of doing it.

Here's another thought:

What if we gave all modules an __all__ automatically, and that was an object
that acted like a list but also had an @public decorator.

import sys

class All(list):
def public(self, api):
sys.modules[api.__module__].__all__.append(api.__name__)

__all__ = All()

@__all__.public
def foo():
pass

@__all__.public
class Bar:
pass

__all__.append('CONST')
CONST = 1

print(__all__)

--

___
Python tracker 

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



[issue21925] ResourceWarning sometimes doesn't display

2016-03-24 Thread STINNER Victor

STINNER Victor added the comment:

It looks like logging a warning at Python exit always works on Python 2.7:
---
import _warnings

class Bla:
def __del__(self, w=_warnings):
w.warn_explicit('message', DeprecationWarning, 'x.py', 5)

bla = Bla()
---

It looks like it uses the Python implementation and linecache.getline() always 
works. Maybe the warning is emitted earlier that the Python 3 code emitting 
ResourceWarning. I see that warnings.py of Python 2 imports linecache at top 
level, whereas the Python 3 code imports the module at the first use in 
showwarning(). I recall that imports at top level are avoided to get faster 
startup time.

--

___
Python tracker 

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



[issue21925] ResourceWarning sometimes doesn't display

2016-03-24 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 1de90a7065ba by Victor Stinner in branch '3.5':
warnings.formatwarning(): catch exceptions
https://hg.python.org/cpython/rev/1de90a7065ba

New changeset 36be356f6253 by Victor Stinner in branch 'default':
Merge 3.5
https://hg.python.org/cpython/rev/36be356f6253

--

___
Python tracker 

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



[issue21925] ResourceWarning sometimes doesn't display

2016-03-24 Thread STINNER Victor

STINNER Victor added the comment:

I fixed warnings.formatwarning(). I don't expect the code to be perfect (Python 
shutdown process is complex and fragile), but the fix is quite simple and it's 
enough to fix the bug described in the initial message. I even added an unit 
test for it.

I didn't try to force when the __main__ module is unloaded, I didn't see any 
consensus around that.

Thanks for the bug report, it's now fixed ;-) Sorry for the delay. We had to 
fix a million of other subtle issues to make the Python shutdown process and 
the stdlib stronger.

--
resolution:  -> fixed
status: open -> closed
versions: +Python 3.6 -Python 3.4

___
Python tracker 

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



[issue26637] importlib: better error message when import fail during Python shutdown

2016-03-24 Thread STINNER Victor

Changes by STINNER Victor :


--
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



[issue26637] importlib: better error message when import fail during Python shutdown

2016-03-24 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 14c56f697a85 by Victor Stinner in branch 'default':
Fix bug in __import__ during Python shutdown
https://hg.python.org/cpython/rev/14c56f697a85

--
nosy: +python-dev

___
Python tracker 

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



[issue25951] SSLSocket.sendall() does not return None on success like socket.sendall()

2016-03-24 Thread Martin Panter

Martin Panter added the comment:

Agreed that the documentation and implementation should match. But this seems 
like a rather low-priority bug. What use case relies on the return value being 
None?

If there is no immediate need for this change, it might be safer to just make 
it in 3.6, to minimize compatibility problems. But if it is fixed in 3.5 it 
should also be fixed in 2.7.

I left some suggestions to simplify the code.

--
nosy: +martin.panter
stage:  -> patch review

___
Python tracker 

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



[issue26632] __all__ decorator

2016-03-24 Thread Ethan Furman

Ethan Furman added the comment:

Not a fan.  :/

How about getting your own copy of the public decorator initialized with the 
globals you pass in?

class Public:
def __init__(self, module):
"""
module should be the globals() dict from the calling module
"""
self.module = module
self.module.setdefault('__all__', [])
def __call__(self, thing, value=None):
if isinstance(thing, str):
self.module[thing] = value
else:
self.module[thing.__name__] = thing

and in use:

public = Public(globals())

@public
def baz(a, b):
#blah blah

public('CONST1', 2)

--

___
Python tracker 

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



[issue26632] __all__ decorator

2016-03-24 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

On Mar 25, 2016, at 12:14 AM, Ethan Furman wrote:

>public = Public(globals())
>
>@public
>def baz(a, b):
>#blah blah
>
>public('CONST1', 2)

I'm not crazy about that, plus I rather don't like the implicit binding of the
name.  I suppose we should just drop the idea of convenience for non-"API".
Just use the defined @public for classes and functions, and an explicit
__all__.append('CONST') for other names.

--

___
Python tracker 

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



[issue25654] test_multiprocessing_spawn ResourceWarning with -Werror

2016-03-24 Thread STINNER Victor

STINNER Victor added the comment:

Oh, with fixes for issues #21925 and #26637, test_multiprocessing_spawn started 
to fail:

http://buildbot.python.org/all/builders/AMD64%20Debian%20root%203.5/builds/727/steps/test/logs/stdio

==
FAIL: test_sys_exit 
(test.test_multiprocessing_spawn.WithProcessesTestSubclassingProcess)
--
Traceback (most recent call last):
  File 
"/root/buildarea/3.5.angelico-debian-amd64/build/Lib/test/_test_multiprocessing.py",
 line 483, in test_sys_exit
self.assertEqual(f.read().rstrip(), str(reason))
AssertionError: "[1, 2, 3]\nsys:1: ResourceWarning: unclo[67 chars]-8'>" != 
'[1, 2, 3]'
- [1, 2, 3]
?  -
+ [1, 2, 3]- sys:1: ResourceWarning: unclosed file <_io.TextIOWrapper 
name='/dev/null' mode='r' encoding='UTF-8'>

--

___
Python tracker 

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



[issue26076] redundant checks in tok_get in Parser\tokenizer.c

2016-03-24 Thread Martin Panter

Martin Panter added the comment:

The change looks pretty good to me.

I guess some test cases could be added to Lib/test/test_grammar.py, unless 
there is somewhere else that already tests this sort of stuff.

--
nosy: +martin.panter

___
Python tracker 

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



[issue26620] Fix ResourceWarning warnings in test_urllib2_localnet

2016-03-24 Thread Martin Panter

Martin Panter added the comment:

This handling of KeyboardInterrupt seems like a bug with unittest IMO. But 
personally I don’t spend too much thought or code handling KeyboardInterrupt in 
tests, for similar reasons to not doing special handling of test failures in 
Issue 26612.

--

___
Python tracker 

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



[issue23551] IDLE to provide menu link to PIP gui.

2016-03-24 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Upendra and Eric: get_list_data() should first parse the string into a list of 
lines with .splitlines.  At some point, I think the scrolled list should become 
a scrolled ttk.Treeview, which can have multiple columns.  Then get_line_data 
should parse each line into name and version.  Then a third column can be added 
to indicate that a newer version is available.  I wish I had that right now.  I 
have forgotten how to get the update-available info.

Alexander, the screenshot could not be more timely.  I was thinking of only 
putting something in the third column when an update is available, but that is 
a minor detail.

In any case, the point is that the  get_list_data should eventually prepare a 
package-list-specific list of triples that gets fed to show_list_data.

--

___
Python tracker 

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



[issue23551] IDLE to provide menu link to PIP gui.

2016-03-24 Thread Terry J. Reedy

Terry J. Reedy added the comment:

As I said on core-mentorship list, I decided that we should use Raymond's 
initial list for the feature list.  If anyone has any elaborations or 
additions, now is the time to post them.

--

___
Python tracker 

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



[issue26632] __all__ decorator

2016-03-24 Thread Eryk Sun

Eryk Sun added the comment:

> work off its __name__ and __module__

Why is __module__ required? It seems to me this should only operate on the 
current module. 

I added a prototype to Python/bltinmodule.c that gets or creates the __all__ 
list from the current globals (i.e. PyEval_GetGlobals). It accepts at most one 
positional argument and any number of keyword arguments. It adds the positional 
argument's __name__ to __all__, sets it in globals, and returns a reference for 
use as a decorator. The keyword argument dict is used to update globals and 
extend __all__. 

Python 3.6.0a0 (default:3eec7bcc14a4+, Mar 24 2016, 20:40:52) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more
information.
>>> @public
... def foo():
... pass
... 
>>> def bar(): pass
... 
>>> public(bar, spam=1, eggs=2)

>>> __all__
['foo', 'spam', 'eggs', 'bar']
>>> foo, bar
(, )
>>> spam, eggs
(1, 2)

Maybe it should be generalized to handle multiple positional arguments. 
Currently it's an error:

>>> public(foo, bar)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: public expected at most 1 arguments, got 2

The positional argument must have a __name__ that's a string:

>>> public('CONST')
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'str' object has no attribute '__name__'
>>> class C:
... __name__ = 1
... 
>>> public(C())
Traceback (most recent call last):
  File "", line 1, in 
TypeError: __name__ must be a string

If it's used to decorate a method definition, it stores a reference to the 
function in the module's globals. That's not very useful, but at least it won't 
lead to an error with a star import.

--
nosy: +eryksun

___
Python tracker 

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



[issue26628] Undefined behavior calling C functions with ctypes.Union arguments

2016-03-24 Thread Eryk Sun

Eryk Sun added the comment:

> I would strongly argue to generally prohibit this 
> with an exception

I agree. A warning in the tutorial isn't sufficient. ctypes should raise an 
error when setting a union or bitfield struct type in argtypes or when passing 
one by value.

Here's some background to flesh out this issue. Both struct and union types are 
defined as the libffi type FFI_TYPE_STRUCT (13), since FFI_TYPE_UNION doesn't 
exist. 

class MyUnion(ctypes.Union):
_fields_ = [("x%s" % i, ctypes.c_double) for i in range(11)]

>>> stgdict(MyUnion).length
11
>>> stgdict(MyUnion).ffi_type_pointer
size: 8
alignment: 8
type: 13
elements: 17918992

>>> (ctypes.c_void_p * 12).from_address(17918992)[:]
[140354450953784, 140354450953784, 140354450953784, 140354450953784,
 140354450953784, 140354450953784, 140354450953784, 140354450953784,
 140354450953784, 140354450953784, 140354450953784, None]

>>> ffi_type.from_address(140354450953784)
size: 8
alignment: 8
type: 3
elements: LP_LP_ffi_type()

Type 3 is FFI_TYPE_DOUBLE.

class MyStruct(ctypes.Structure):
_fields_ = [("x%s" % i, ctypes.c_double) for i in range(11)]

>>> stgdict(MyStruct).length
11
>>> stgdict(MyStruct).ffi_type_pointer
size: 88
alignment: 8
type: 13
elements: 17868096
>>> (ctypes.c_void_p * 12).from_address(17868096)[:]
[140354450953784, 140354450953784, 140354450953784, 140354450953784,
 140354450953784, 140354450953784, 140354450953784, 140354450953784,
 140354450953784, 140354450953784, 140354450953784, None]

As shown above, FFI_TYPE_STRUCT uses the `elements` array in its ffi_type. Each 
element is a pointer to an ffi_type for the corresponding field in the struct 
or union. This array is terminated by a NULL pointer. 

The C data size of a MyUnion instance is 8 bytes. This is less than 32 bytes 
(i.e. four 8-byte words), so the code in classify_argument rightfully assumes 
the argument won't be passed on the stack. Thus it classifies the register 
type(s) to use, presuming it's dealing with a struct. But since it's a union 
the total size of the elements is unrelated to the union's size. libffi would 
need to implement an FFI_TYPE_UNION type to support this as a separate case. 
Otherwise ctypes needs to actively forbid passing a union by value.

--
nosy: +eryksun
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



[issue26565] [ctypes] Add value attribute to non basic pointers.

2016-03-24 Thread Eryk Sun

Eryk Sun added the comment:

The `value` of a c_char_p or c_wchar_p pointer is a Python bytes or str object. 
Since `value` won't consistently be the address value, it may be better to 
introduce a read-only `as_void` attribute that can be implemented consistently 
for all pointer types (including function pointers). Its value would be the 
same as the `value` of a casted c_void_p (e.g. NULL is mapped to None). The new 
attribute would be added as a getset descriptor in Pointer_getsets and 
PyCFuncPtr_getsets. For simple pointer types, it would have to be added 
specially in PyCSimpleType_new.

--
nosy: +eryksun
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



[issue6953] readline documentation needs work

2016-03-24 Thread Martin Panter

Martin Panter added the comment:

Here is a modified patch. Does the new wording for clear_history() clarify 
things for you Berker? In theory that function could be included or omitted for 
both the Gnu Readline and Editline cases.

--
Added file: http://bugs.python.org/file42281/readline-doc.v2.patch

___
Python tracker 

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



[issue8557] subprocess PATH semantics and portability

2016-03-24 Thread Eryk Sun

Eryk Sun added the comment:

As is documented for CreateProcess [1], the search path always includes the 
following directories:

* The directory from which the application loaded.
* The current directory for the parent process.
* The Windows system directory. Use the
  GetSystemDirectory function to get the path of
  this directory.
* The 16-bit Windows system directory. There is no
  function that obtains the path of this directory,
  but it is searched. The name of this directory is
  System.
* The Windows directory. Use the GetWindowsDirectory
  function to get the path of this directory.
* The directories that are listed in the PATH
  environment variable.

The value of PATH comes from the calling process environment, not from the 
environment passed in the lpEnvironment parameter. If you need to search some 
other list of paths, you can use shutil.which to find the fully qualified path 
of the target executable.

Note that in Vista+ you can remove the current directory from the search list 
by defining the environment variable "NoDefaultCurrentDirectoryInExePath" [2]. 

The following examples show the minimum search path that CreateProcess uses 
when PATH isn't defined.

>>> 'PATH' in os.environ
False

>>> subprocess.call('python -Sc "import sys; print(sys.prefix)"')
Breakpoint 0 hit
KERNELBASE!SearchPathW:
7ff9`cf4b5860 488bc4  mov rax,rsp
0:000> du @rcx
006c`a7074410  "C:\Program Files\Python35;.;C:\W"
006c`a7074450  "indows\SYSTEM32\;C:\Windows\syst"
006c`a7074490  "em;C:\Windows"
0:000> g
C:\Program Files\Python35
0

>>> os.environ['NoDefaultCurrentDirectoryInExePath'] = '1'

>>> subprocess.call('python -Sc "import sys; print(sys.prefix)"')
Breakpoint 0 hit
KERNELBASE!SearchPathW:
7ff9`cf4b5860 488bc4  mov rax,rsp
0:000> du @rcx
006c`a6560710  "C:\Program Files\Python35;C:\Win"
006c`a6560750  "dows\SYSTEM32\;C:\Windows\system"
006c`a6560790  ";C:\Windows"
0:000> g
C:\Program Files\Python35
0

Note that in the 2nd case the current directory ('.') is no longer present 
between the application directory ("C:\Program Files\Python35") and the system 
directory ("C:\Windows\SYSTEM32\").

CreateProcess executes PE executables and batch files (run via the %ComSpec% 
interpreter). It automatically appends the .exe extension when searching for an 
executable. It does this via the lpExtension parameter of SearchPath [3]. 

Some .com files are PE executables (e.g. chcp.com). Otherwise it's not really 
usefully to loop over the PATHEXT extensions unless you're using shell=True, 
since most are filetypes that CreateProcess doesn't support [4]. 

[1]: https://msdn.microsoft.com/en-us/library/ms682425
[2]: https://msdn.microsoft.com/en-us/library/ms684269
[3]: https://msdn.microsoft.com/en-us/library/aa365527
[4]: If Microsoft's Windows team cared at all about cross-platform
 idioms they'd add shebang support to CreateProcess, which
 would make all scripts, not just batch files, directly
 executable without requiring ShellExecuteEx and registered
 filetypes. ShellExecuteEx doesn't support a lot of useful
 creation flags that are only available by calling
 CreateProcess directly, and it also doesn't check ACLs to
 prevent executing a file. So scripts are second class
 citizens in Windows, which is why Python has to embed 
 scripts in .exe wrappers.

--
nosy: +eryksun

___
Python tracker 

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



[issue26638] Avoid warnings about missing CLI options when building documentation

2016-03-24 Thread Martin Panter

New submission from Martin Panter:

Defeat many warnings and related fixes building documentation

* Mask various CLI options with exclamation marks (!)
* Correct link to CLI section in zipapp
* Make CLI section label in timeit less ambiguous

The following warnings from unittest remain. Ideally they should be linked to 
the Python CLI documentation, but this does not seem possible because the 
“unittest” documentation defines its own CLI options.

Doc/library/unittest.rst:1965: WARNING: unknown option: -Wd
Doc/library/unittest.rst:1965: WARNING: unknown option: -Wa
Doc/library/unittest.rst:2051: WARNING: unknown option: -W

--
assignee: docs@python
components: Documentation
files: doc-warnings.patch
keywords: patch
messages: 262401
nosy: docs@python, martin.panter
priority: normal
severity: normal
stage: patch review
status: open
title: Avoid warnings about missing CLI options when building documentation
versions: Python 2.7, Python 3.5, Python 3.6
Added file: http://bugs.python.org/file42282/doc-warnings.patch

___
Python tracker 

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



[issue26076] redundant checks in tok_get in Parser\tokenizer.c

2016-03-24 Thread Roundup Robot

Roundup Robot added the comment:

New changeset f0acce8022d1 by Benjamin Peterson in branch 'default':
remove duplicated check for fractions and complex numbers (closes #26076)
https://hg.python.org/cpython/rev/f0acce8022d1

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



[issue23551] IDLE to provide menu link to PIP gui.

2016-03-24 Thread Eric Khoo Jiun Hooi

Eric Khoo Jiun Hooi added the comment:

Terry, now I have done two more mockup for the installed package tab which is 
referenced from your suggestion and belopolsky's suggestion. Which you do 
you prefer? About the http://www.lfd.uci.edu/~gohlke/pythonlibs/ repo that you 
suggested to be added inside, I have done some research about that and it seem 
like pip install --index-url can only search from something like this website 
https://pypi.python.org/simple/ format. So, I think maybe I have to parse the 
package from ttp://www.lfd.uci.edu/~gohlke/pythonlibs/, but without 
description. Is it ok?

--
Added file: http://bugs.python.org/file42283/Design suggested by Terry.png

___
Python tracker 

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



[issue23551] IDLE to provide menu link to PIP gui.

2016-03-24 Thread Eric Khoo Jiun Hooi

Eric Khoo Jiun Hooi added the comment:

One more thing, window should be able to install package with pip. So, why the 
need of http://www.lfd.uci.edu/~gohlke/pythonlibs/ ?

--
Added file: http://bugs.python.org/file42284/Design reference from pycharm.png

___
Python tracker 

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