[issue24959] unittest swallows part of stack trace when raising AssertionError in a TestCase

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
nosy: +ezio.melotti, michael.foord, rbcollins
versions: +Python 3.5, 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



[issue24922] assertWarnsRegex doesn't allow multiple warning messages

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
nosy: +ezio.melotti, michael.foord, rbcollins
stage:  -> needs patch
versions: +Python 3.5, 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




[issue25999] Add support of negative number in bin()

2016-01-03 Thread SonokoMizuki

Changes by SonokoMizuki :


--
title: Add support of native number in bin() -> Add support of negative number 
in bin()

___
Python tracker 

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



[issue26000] Crash in Tokenizer - Heap-use-after-free

2016-01-03 Thread William Bowling

William Bowling added the comment:

Also a very similar source causes a slightly different crash 
(heap-buffer-overflow instead of heap-use-after-free):

./python -c 'with open("vuln2.py", "wb") as f: 
f.write(b"\x61\x73\x00\x0a\x79\x6e\x63\x5c\x0a\x00\x0d\xdd")'
./python vuln2.py

Python 3.5.1+ (default, Jan  4 2016, 00:05:40)

Attached the asan report

--
Added file: http://bugs.python.org/file41487/asan2.txt

___
Python tracker 

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



[issue25641] urllib/request.py/getproxies_environment() throws "dictionary changed size during iteration" error occasionally

2016-01-03 Thread Senthil Kumaran

Senthil Kumaran added the comment:

os.environ is never changed by getproxies_environment()

Like Martin Panter, I will curious to know as how the user experienced this 
issue in the place.

@Raymond Hettinger: If the dict is only read and never modified in the fuction, 
does it still make sense to have a defensive list() as you suggested? If yes, 
then there will be couple of places in the stdlib code that will need this 
change.

```
$ ag os.environ.items Lib
Lib/distutils/_msvccompiler.py
80:for key, value in os.environ.items()

Lib/test/test_os.py
679:for key, val in os.environ.items():

Lib/test/test_wsgiref.py
427:os_environ = dict(os.environ.items())

Lib/urllib/request.py
2453:for name, value in os.environ.items():

Lib/wsgiref/handlers.py
47:for k, v in os.environ.items():
```

My understanding is, if the function is not manipulation and only reading the 
dictionary, a defensive list or copy is not required. And, this bug report 
should be closed.

--
nosy: +orsenthil
status: open -> pending

___
Python tracker 

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



[issue25282] regex: Support for recursive patterns

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
components: +Regular Expressions
nosy: +ezio.melotti, mrabarnett
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



[issue25609] Add a ContextManager ABC and type

2016-01-03 Thread Guido van Rossum

Guido van Rossum added the comment:

The abstract base class would be an ABC providing documentation and a template 
for implementations, and a way to test using isinstance(). This is how several 
other ABCs are used that have no particularly useful default implementation.

In addition, the presence of the ABC provides a reference for corresponding 
class in the typing module (used to express type hints using PEP 484) -- again 
this is just following the example of the other ABCs.

--

___
Python tracker 

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



[issue25919] http.client PUT method ignores error responses sent immediatly after headers

2016-01-03 Thread Martin Panter

Martin Panter added the comment:

Curl uses “Expect: 100-continue”. This is the relevant output from it:

$ curl -v -T 300mb --no-fail 
https://api.onedrive.com/v1.0/drives/me/root:/test.file:/content
[. . .]
> PUT /v1.0/drives/me/root:/test.file:/content HTTP/1.1
> Host: api.onedrive.com
> Content-Range: bytes 0-314572799/314572800
> User-Agent: curl/7.43.0
> Accept: */*
> Connection: TE
> TE: gzip
> Content-Length: 314572800
> Expect: 100-continue
> 
< HTTP/1.1 413 Request Entity Too Large
< Content-Length: 0
< Server: Microsoft-HTTPAPI/2.0
< P3P: CP="BUS CUR CONo FIN IVDo ONL OUR PHY SAMo TELo"
< X-MSNSERVER: DM2302PAP179
< Strict-Transport-Security: max-age=31536000; includeSubDomains
< X-ThrowSite: 7c11.e25d
< Date: Sun, 03 Jan 2016 20:04:27 GMT
* HTTP error before end of send, stop sending
< 
* Closing connection 0

See Issue 1346874 about support for 100-continue mode.

When I tried your test code on Linux, it hung for two minutes, and then raised 
ConnectionResetError. I guess the server refused to receive data, and then 
timed the connection out. The patch should handle this in most cases, but I 
think there could still a race between select() returning an empty rlist, and 
then the server sending a request and causing the upload to hang. Also, there 
is nothing to protect from sendall() partially uploading a chunk, and then 
hanging.

It should be more robust to check for both send and receive sides of the socket 
with select(), and only use send(), not sendall(), to avoid blocking.

I would consider this a new feature, so I don’t think it should go into 3.5. It 
would be good to add documentation and test cases as well.

Wiktor’s problem is similar to the situations in Issue 5542. There, the 
original poster seemed happy to wait for a broken pipe error, and then inspect 
a 401 Unauthorized response. This apparently was made to work with plain HTTP 
over TCP, but not HTTPS.

I wonder if having request() silently return is the best API design. Is there a 
possibility that the caller would want to distinguish a successful upload from 
an aborted one? I can’t think of one, but it seems plausible.

Another related enhancement I would like is the ability to detect an error 
response (e.g. 408 Request Timeout) or dropped connection _before_ even sending 
a request. This is useful with persistent connections; see items 1 and 2 in 
.

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



[issue8728] 2.7 regression in httplib.py: AttributeError: 'NoneType' object has no attribute 'makefile'

2016-01-03 Thread Senthil Kumaran

Senthil Kumaran added the comment:

Closing this since no further update was available from the original reporter. 
If this bug is still present, please open a new issue with test case to 
reproduce.

--
nosy: +orsenthil
resolution:  -> not a bug
stage:  -> resolved
status: pending -> closed

___
Python tracker 

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



[issue25423] Deprecate benchmarks that execute too quickly

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
keywords: +easy
nosy: +ezio.melotti
stage:  -> needs patch
type:  -> behavior

___
Python tracker 

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



[issue25866] Reference 3. Data Model: miscellaneous minor cleanups on the word "sequence".

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
keywords: +easy
nosy: +ezio.melotti
stage:  -> needs patch
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



[issue25810] Python 3 documentation for eval is incorrect

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
nosy: +ezio.melotti
type:  -> enhancement
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



[issue24632] Improve documentation about __main__.py

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


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



[issue25179] PEP 498 f-strings need to be documented

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
type:  -> enhancement

___
Python tracker 

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



[issue25381] Doc: Use of old description of raise in Python3

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
nosy: +ezio.melotti
type:  -> enhancement
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



[issue25347] assert_has_calls output is formatted inconsistently

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
nosy: +ezio.melotti
stage:  -> patch review

___
Python tracker 

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



[issue25743] Clarify exactly what \w matches in UNICODE mode

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
components: +Regular Expressions
nosy: +ezio.melotti, mrabarnett
stage:  -> needs patch
type:  -> enhancement
versions:  -Python 3.2, 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



[issue24780] unittest assertEqual difference output foiled by newlines

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
keywords: +easy
nosy: +ezio.melotti, michael.foord, rbcollins
stage:  -> test needed
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



[issue24898] Documentation for str.find() is confusing

2016-01-03 Thread Senthil Kumaran

Senthil Kumaran added the comment:

Updated the docs as per Georg's suggestion. Thank you Ted Lemon for bringing 
this up.

--
assignee: docs@python -> orsenthil
nosy: +orsenthil
resolution:  -> fixed
stage: needs patch -> resolved
status: open -> closed
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



[issue24898] Documentation for str.find() is confusing

2016-01-03 Thread Roundup Robot

Roundup Robot added the comment:

New changeset da934a19855b by Senthil Kumaran in branch '2.7':
Backport documentation improvement.
https://hg.python.org/cpython/rev/da934a19855b

--

___
Python tracker 

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



[issue25197] Allow documentation switcher to change url to /3/ and /dev/

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
nosy: +ezio.melotti, georg.brandl
stage:  -> patch review

___
Python tracker 

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



[issue25403] urllib.parse.urljoin is broken in python 3.5

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
nosy: +ezio.melotti

___
Python tracker 

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



[issue23677] Mention dict and set comps in library reference

2016-01-03 Thread Martin Panter

Martin Panter added the comment:

The distiction about non-empty sets is a bit misleading. You can create an 
empty set via comprehension:

>>> {x for x in ()}
set()

--
nosy: +martin.panter

___
Python tracker 

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



[issue24733] Logically Dead Code

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
stage:  -> patch review
type:  -> enhancement

___
Python tracker 

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



[issue24715] Sorting HOW TO: bad example for reverse sort stability

2016-01-03 Thread Ezio Melotti

Ezio Melotti added the comment:

LGTM, however I would also show the sorted output too.

--
nosy: +ezio.melotti
stage:  -> commit review
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



[issue26001] Tutorial: write() does not expect string in binary mode

2016-01-03 Thread Upendra Kumar

Upendra Kumar added the comment:

I also think that for better clarification, binary mode and text mode should be 
specified clearly for both methods read() and write(). 

For read(), I have changed it to:

' some quantity of data and returns it as a string (in text mode) or bytes 
object (in binary mode).'

For write(), I have changed it to:

' To write something other than a string (in text mode) or bytes object (in 
binary mode), it needs to be converted first to string or bytes object 
respectively. '

Please if someone could review it, as I have not submitted a patch related to 
docs before. And I am not sure, if I have made correct changes at right place.

--
keywords: +patch
nosy: +upendra-k14
Added file: http://bugs.python.org/file41486/fileiotutorial.patch

___
Python tracker 

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



[issue25517] regex howto example in "Lookahead Assertions"

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
components: +Regular Expressions
nosy: +ezio.melotti, mrabarnett
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



[issue25433] whitespace in strip()/lstrip()/rstrip()

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
keywords: +easy
nosy: +ezio.melotti
stage:  -> needs patch
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



[issue24520] Stop using deprecated floating-point environment functions on FreeBSD

2016-01-03 Thread Andrew Turner

Andrew Turner added the comment:

Can this be applied?

--

___
Python tracker 

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



[issue24896] It is undocumented that re.UNICODE affects re.IGNORECASE

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
components: +Regular Expressions
nosy: +ezio.melotti, mrabarnett
stage:  -> needs patch
type:  -> enhancement
versions: +Python 3.5, 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



[issue24898] Documentation for str.find() is confusing

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
keywords: +easy
stage:  -> needs patch
type:  -> enhancement
versions: +Python 2.7, Python 3.5

___
Python tracker 

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



[issue24918] Docs layout bug

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
keywords: +easy
nosy: +ezio.melotti
versions:  -Python 3.2, 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



[issue24898] Documentation for str.find() is confusing

2016-01-03 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 7150e8a38c63 by Senthil Kumaran in branch '3.4':
Issue24898 - Improve str.find documentation.
https://hg.python.org/cpython/rev/7150e8a38c63

New changeset 164b564e3c1a by Senthil Kumaran in branch '3.5':
merge from 3.4
https://hg.python.org/cpython/rev/164b564e3c1a

New changeset 136adbcefa5f by Senthil Kumaran in branch 'default':
merge from 3.5
https://hg.python.org/cpython/rev/136adbcefa5f

--
nosy: +python-dev

___
Python tracker 

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



[issue25547] Improve repr for files to show whether the file is open or closed.

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
resolution:  -> not a bug
stage: needs patch -> resolved
status: open -> pending

___
Python tracker 

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



[issue25919] http.client PUT method ignores error responses sent immediatly after headers

2016-01-03 Thread Martin Panter

Martin Panter added the comment:

For non-blocking SSL sockets, the Python documentation suggests the results of 
select() do not directly indicate if data can be sent or received: 
. I guess this 
would also apply to blocking SSL sockets.

--

___
Python tracker 

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



[issue24612] not operator expression raising a syntax error

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
nosy: +ezio.melotti
versions: +Python 3.5, 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



[issue19006] UnitTest docs should have a single list of assertions

2016-01-03 Thread Kushal Das

Kushal Das added the comment:

The patch looks good to me. Commit :)

--

___
Python tracker 

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



[issue25940] SSL tests failed due to expired svn.python.org SSL certificate

2016-01-03 Thread Martin Panter

Martin Panter added the comment:

Assuming it is practical, would it be appropriate to convert the failing tests 
to connect to a local server running in a background Python thread? Perhaps 
using the existing ThreadedEchoServer. That way the tests wouldn’t require an 
internet connection, and the certificates used etc should be all contained 
within the Python source tree.

--
nosy: +martin.panter

___
Python tracker 

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



[issue24733] Logically Dead Code

2016-01-03 Thread Martin Panter

Martin Panter added the comment:

This looks like some leftover cruft after refactoring the code: 
. Removing 
it looks fine to me.

This does not seem to be applicable to Python 3.

--
nosy: +martin.panter

___
Python tracker 

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



[issue25940] SSL tests failed due to expired svn.python.org SSL certificate

2016-01-03 Thread Martin Panter

Martin Panter added the comment:

In the meantime, this patch changes the tests to use the new DST root 
certificate. This seems to be the minimum to make the tests pass again, but 
someone else should probably review it because I’m not too experienced with SSL 
certificate stuff.

--
keywords: +patch
stage:  -> patch review
Added file: http://bugs.python.org/file41488/svn-cert.patch

___
Python tracker 

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



[issue25995] os.walk() consumes a lot of file descriptors

2016-01-03 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here are two alternative solutions for this issue.

--
keywords: +patch
stage:  -> patch review
Added file: http://bugs.python.org/file41482/walk_consume_fds_opt1.patch

___
Python tracker 

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



[issue25995] os.walk() consumes a lot of file descriptors

2016-01-03 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


Added file: http://bugs.python.org/file41483/walk_consume_fds_opt2.patch

___
Python tracker 

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



[issue23677] Mention dict and set comps in library reference

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
nosy: +ezio.melotti
stage:  -> patch review
type:  -> enhancement
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



[issue23702] docs.python.org/3/howto/descriptor.html still refers to "unbound methods"

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
versions: +Python 3.5, 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



[issue23675] glossary entry for 'method resolution order' links to something with python 2.3 in the title

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
assignee:  -> docs@python
components: +Documentation
keywords: +easy
nosy: +docs@python, ezio.melotti
stage:  -> needs patch
type:  -> enhancement

___
Python tracker 

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



[issue23986] Inaccuracy about "in" keyword for list and tuple

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
stage:  -> patch review

___
Python tracker 

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



[issue21221] Minor struct_time documentation bug

2016-01-03 Thread Roundup Robot

Roundup Robot added the comment:

New changeset fae779a811ec by Senthil Kumaran in branch '3.4':
Issue21221 - Explain the usage of tm_isdst attribute of mktime, with valid
https://hg.python.org/cpython/rev/fae779a811ec

New changeset 3b7a7ea1214c by Senthil Kumaran in branch '3.5':
merge from 3.4
https://hg.python.org/cpython/rev/3b7a7ea1214c

New changeset b729e7ae2747 by Senthil Kumaran in branch 'default':
merge from 3.5
https://hg.python.org/cpython/rev/b729e7ae2747

--
nosy: +python-dev

___
Python tracker 

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



[issue21221] Minor struct_time documentation bug

2016-01-03 Thread Roundup Robot

Roundup Robot added the comment:

New changeset f7324e5935f8 by Senthil Kumaran in branch '2.7':
Backport doc improvements for Issue21221 - Explain the usage of tm_isdst
https://hg.python.org/cpython/rev/f7324e5935f8

--

___
Python tracker 

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



[issue21221] Minor struct_time documentation bug

2016-01-03 Thread Senthil Kumaran

Changes by Senthil Kumaran :


--
assignee: docs@python -> orsenthil
nosy: +orsenthil
resolution:  -> fixed
status: open -> closed
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



[issue12606] Mutable Sequence Type works different for lists and bytearrays in slice[i:j:k]

2016-01-03 Thread py.user

py.user added the comment:

Also memoryview() doesn't support:

>>> m = memoryview(bytearray(b'abcde'))
>>> m[::2] = ()
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'tuple' does not support the buffer interface
>>> m[::2] = b''
Traceback (most recent call last):
  File "", line 1, in 
ValueError: memoryview assignment: lvalue and rvalue have different structures
>>> m[::2] = b'123'
>>> m.tobytes()
b'1b2d3'
>>>

--

___
Python tracker 

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



[issue24056] Better expose closure, generator & coroutine status of functions

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
nosy: +ezio.melotti

___
Python tracker 

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



[issue21593] Clarify re.search documentation first match

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
components: +Regular Expressions
nosy: +ezio.melotti, mrabarnett
stage: resolved -> commit review
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



[issue23664] Modernize HTML output of difflib.HtmlDiff.make_file()

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
nosy: +ezio.melotti
versions: +Python 3.6 -Python 3.5

___
Python tracker 

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



[issue25999] Add support of native number in bin()

2016-01-03 Thread SonokoMizuki

New submission from SonokoMizuki:

Add support of negative number in bin().
Currently, bin(-5) returns '-0b101', It is not intuitive.
I think bin() should return two's complement.

I suggest new bin().
New second argument is bit size.
if first argument is negative number and bit size is given, bin() will return 
two's complement.

example)
>>> bin(12)
'0b1100'
>>> bin(-12)
'-0b1100'
>>> bin(-12,8)
'0b0100'
>>> bin(-12,3) # if not enough bit size, bin will return value as usual.
'-0b100'

--
components: Argument Clinic
messages: 257408
nosy: larry, mizuki
priority: normal
severity: normal
status: open
title: Add support of native number in bin()
type: behavior
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



[issue25596] regular files handled as directories in the glob module

2016-01-03 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I think so too. I just wanted someone to confirmed that it is not 
overcautiousness. For now glob1() is used only in one place in the stdlib 
(issue16620).

But there was other problem with previous patch, the same as with current 
implementation of os.walk() (issue25995). It makes glob to use a lot of file 
descriptors.

Updated patch lefts deprecated glob1() and glob2() and makes glob to consume 
all scandir iterator before starting to yield values (but the problem with fd 
leaks on non-refcounted implementations is still left, issue25994). This 
doesn't affect performance, but lefts the issue with delaying (issue22167).

--
dependencies: +File descriptor leaks in os.scandir()
Added file: http://bugs.python.org/file41481/glob_scandir_2.patch

___
Python tracker 

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



[issue23762] python.org page on new-style classes should be updated

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
resolution:  -> third party
status: open -> pending

___
Python tracker 

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



[issue25596] regular files handled as directories in the glob module

2016-01-03 Thread Xavier de Gaye

Xavier de Gaye added the comment:

I may be missing something, anyway here are few comments on the patch:
Is the call to entry.is_symlink() in _iterdir() necessary since is_dir() 
follows symlinks ?
If _iterdir() would yield the DirEntry instance instead of DirEntry.name, then 
_rlistdir() could use x.is_dir() to know whether it is correct to iterate over 
_rlistdir(x.path, dironly)

--

___
Python tracker 

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



[issue25596] regular files handled as directories in the glob module

2016-01-03 Thread Xavier de Gaye

Xavier de Gaye added the comment:

os.scandir() is called recursively in the last patch and the file descriptors 
are not closed until returning from the recursion.
The glob functions should fail explicitly when scandir() raises OSERROR with 
posix errno set to EMFILE (The process has too many files open), or even 
better, silently ignore only the PermissionError exception instead of ignoring 
OSERROR.

--

___
Python tracker 

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



[issue25997] Tarfile.add with bytes path is failing

2016-01-03 Thread Patrik Dufresne

Patrik Dufresne added the comment:

It's a bit tricky, but with help of surrogateescape I get the expected result.

I'm closing this bug.

Thanks

--
status: open -> closed

___
Python tracker 

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



[issue26000] Crash in Tokenizer - Heap-use-after-free

2016-01-03 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
assignee:  -> serhiy.storchaka
nosy: +serhiy.storchaka
priority: normal -> high

___
Python tracker 

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



[issue21592] Make statistics.median run in linear time

2016-01-03 Thread Julian Taylor

Julian Taylor added the comment:

the median of median of 5 is quite significantly slower than a quickselect.
numpy implements an introselect which uses quickselect but falls back to median 
of median of 5 if not enough progress is done.
In the numpy implementation for 10 element median (multiselect with 2 
selections, one median one min) quickselect is around 3 times faster than mom5

--

___
Python tracker 

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



[issue25999] Add support of native number in bin()

2016-01-03 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Use bin(n & (2**bitsize-1)).

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue25999] Add support of native number in bin()

2016-01-03 Thread Peter Otten

Peter Otten added the comment:

How would you disambiguate -1 and (for example) 2**64-1 on a 64-bit machine? 
Python's int is not limited to a specific number of bits.

--
nosy: +peter.otten

___
Python tracker 

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



[issue22499] [SSL: BAD_WRITE_RETRY] bad write retry in _ssl.c:1636

2016-01-03 Thread Stefan Krah

Stefan Krah added the comment:

As I said in msg254389, the read/write handling for non-blocking
sockets is far from trivial.

I'm not sure that this is a Python bug:

Looking at dugong/__init__.py, I don't think this implements the
recommendations in the OpenSSL book that I mentioned.

The book recommends to keep a state ...

struct iostate {
int read_waiton_write;
int read_waiton_read;
int write_waiton_write;
int write_waiton_read;
int can_read;
int can_write;
};

... a check_availability() function that sets 'can_read', 'can_write'

... a write_allowed() function that determines whether a write is
even possible to attempt ...

int write_allowed(struct iostate *state)
{
if (state->read_waiton_write || state->read_waiton_read)
return 0;
if (state->can_write)
return 1;
if (state->can_read && state->write_waiton_read)
return 1;

return 0;
}

... and finally, the glorious loop:

while (!done) {

while (check_availability(ssl, ) == -1 || 
!state.can_write)
nanosleep(, NULL);


if (write_allowed()) {

state.write_waiton_read = 0;
state.write_waiton_write = 0;

retval = SSL_write(ssl, wbuf, strlen(wbuf));
switch (SSL_get_error(ssl, retval)) {
case SSL_ERROR_NONE:
done = 1;
break;
case SSL_ERROR_ZERO_RETURN:
log_sslerr();
return -1;
break;
case SSL_ERROR_WANT_READ:
state.write_waiton_read = 1;
break;
case SSL_ERROR_WANT_WRITE:
state.write_waiton_write = 1;
break;
default:
log_sslerr();
break;
}
}
}

--

___
Python tracker 

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



[issue25999] Add support of native number in bin()

2016-01-03 Thread Eryk Sun

Eryk Sun added the comment:

bin() returns a Python literal, which thankfully requires an explicit sign. 2's 
complement literals would be prone to human error. If you want 2's complement, 
you can write your own function. For example:

def mybin(number, nbits=None, *, signed=True):
if not signed and number < 0:
raise ValueError('number must be non-negative')
if nbits is None:
return bin(number)
bit_length = number.bit_length()
if signed and number != -2 ** (bit_length - 1):
bit_length += 1
if nbits < bit_length:
raise ValueError('%d requres %d bits' % (number, bit_length))
number &= 2 ** nbits - 1
return format(number, '#0%db' % (nbits + 2))

>>> mybin(12)
'0b1100'
>>> mybin(-12)
'-0b1100'
>>> mybin(12, 8)
'0b1100'
>>> mybin(-12, 8)
'0b0100'

>>> mybin(12, 4)
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 10, in mybin
ValueError: 12 requres 5 bits

Obviously when parsing a number you need to know whether it's two's complement 
or unsigned.

>>> mybin(12, 4, signed=False)
'0b1100'
>>> mybin(-4, 4)
'0b1100'

--
nosy: +eryksun

___
Python tracker 

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



[issue25999] Add support of native number in bin()

2016-01-03 Thread SonokoMizuki

SonokoMizuki added the comment:

I see.
I grasp to write own function is best.
thanks (^-^)

--

___
Python tracker 

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



[issue26002] make statistics.median_grouped more efficient

2016-01-03 Thread Upendra Kumar

New submission from Upendra Kumar:

statistics.median_grouped currently uses cf=data.index(x) to find the leftmost 
position of x in data ( line number 445 ). Here, data.index() has linear time 
complexity, which may not be good for long lists.

But, here since the list 'data' is sorted beforehand, we can use binary search 
( bisect_left() ) to find the leftmost occurrence of 'x' in 'data'. 

Similarly, for counting number of occurrence of 'x' in data after sorting, we 
can find the position of rightmost occurrence of 'x' in data[l1len(data)], 
where l1 is position of leftmost occurrence of 'x' (line number 447 )

--
components: Library (Lib)
files: median_grouped.patch
keywords: patch
messages: 257419
nosy: upendra-k14
priority: normal
severity: normal
status: open
title: make statistics.median_grouped more efficient
type: performance
versions: Python 3.4, Python 3.5, Python 3.6
Added file: http://bugs.python.org/file41484/median_grouped.patch

___
Python tracker 

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



[issue25999] Add support of native number in bin()

2016-01-03 Thread SilentGhost

Changes by SilentGhost :


--
components: +Interpreter Core -Argument Clinic
versions:  -Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5

___
Python tracker 

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




[issue25999] Add support of native number in bin()

2016-01-03 Thread SonokoMizuki

SonokoMizuki added the comment:

It is nice solution. I can get negative number all right. thanks
but, I feel bad that bin(-5) returns '-0b101'
sorry

--

___
Python tracker 

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



[issue26000] Crash in Tokenizer - Heap-use-after-free

2016-01-03 Thread William Bowling

New submission from William Bowling:

Similar to https://bugs.python.org/issue25388 the following causes a crash on 
3.5.1 and the latest 3.5 branch:

./python -c 'with open("vuln.py", "wb") as f: 
f.write(b"\x61\x73\x00\x0a\x79\x6e\x63\x5c\x0a\xef")'
./python vuln.py


Python 3.5.1+ (default, Jan  4 2016, 00:05:40) 
=
==24400==ERROR: AddressSanitizer: heap-use-after-free on address 0xf270f100 at 
pc 0x080ad09e bp 0xffef5ee8 sp 0xffef5ac0
READ of size 2 at 0xf270f100 thread T0
#0 0x80ad09d in strncpy (/home/will/python/cpython/python+0x80ad09d)
#1 0x8589b56 in parsetok /home/will/python/cpython/Parser/parsetok.c:235:13
#2 0x858b301 in PyParser_ParseFileObject 
/home/will/python/cpython/Parser/parsetok.c:134:12
#3 0x8439e0b in PyParser_ASTFromFileObject 
/home/will/python/cpython/Python/pythonrun.c:1150:15
#4 0x843aa37 in PyRun_FileExFlags 
/home/will/python/cpython/Python/pythonrun.c:916:11
#5 0x8438a98 in PyRun_SimpleFileExFlags 
/home/will/python/cpython/Python/pythonrun.c:396:13
#6 0x84382a6 in PyRun_AnyFileExFlags 
/home/will/python/cpython/Python/pythonrun.c:80:16
#7 0x813f194 in run_file /home/will/python/cpython/Modules/main.c:318:11
#8 0x813f194 in Py_Main /home/will/python/cpython/Modules/main.c:768
#9 0x8138070 in main /home/will/python/cpython/./Programs/python.c:69:11
#10 0xf7558496 in __libc_start_main (/usr/lib32/libc.so.6+0x18496)
#11 0x80715b7 in _start (/home/will/python/cpython/python+0x80715b7)

0xf270f100 is located 0 bytes inside of 8194-byte region [0xf270f100,0xf2711102)
freed by thread T0 here:
#0 0x810c2a4 in __interceptor_cfree.localalias.1 
(/home/will/python/cpython/python+0x810c2a4)
#1 0x8139560 in _PyMem_RawFree 
/home/will/python/cpython/Objects/obmalloc.c:90:5
#2 0x813852b in PyMem_Free 
/home/will/python/cpython/Objects/obmalloc.c:349:5
#3 0x8596b05 in error_ret /home/will/python/cpython/Parser/tokenizer.c:198:9
#4 0x8596b05 in decoding_fgets 
/home/will/python/cpython/Parser/tokenizer.c:636
#5 0x8594df0 in tok_nextc 
/home/will/python/cpython/Parser/tokenizer.c:1016:21
#6 0x858ebba in tok_get /home/will/python/cpython/Parser/tokenizer.c:1457:13
#7 0x858fc79 in tok_get /home/will/python/cpython/Parser/tokenizer.c:1524:34
#8 0x858e1da in PyTokenizer_Get 
/home/will/python/cpython/Parser/tokenizer.c:1804:18
#9 0x85899a7 in parsetok /home/will/python/cpython/Parser/parsetok.c:208:16
#10 0x858b301 in PyParser_ParseFileObject 
/home/will/python/cpython/Parser/parsetok.c:134:12
#11 0x8439e0b in PyParser_ASTFromFileObject 
/home/will/python/cpython/Python/pythonrun.c:1150:15
#12 0x843aa37 in PyRun_FileExFlags 
/home/will/python/cpython/Python/pythonrun.c:916:11
#13 0x8438a98 in PyRun_SimpleFileExFlags 
/home/will/python/cpython/Python/pythonrun.c:396:13
#14 0x84382a6 in PyRun_AnyFileExFlags 
/home/will/python/cpython/Python/pythonrun.c:80:16
#15 0x813f194 in run_file /home/will/python/cpython/Modules/main.c:318:11
#16 0x813f194 in Py_Main /home/will/python/cpython/Modules/main.c:768
#17 0x8138070 in main /home/will/python/cpython/./Programs/python.c:69:11
#18 0xf7558496 in __libc_start_main (/usr/lib32/libc.so.6+0x18496)

previously allocated by thread T0 here:
#0 0x810c784 in realloc (/home/will/python/cpython/python+0x810c784)
#1 0x8139541 in _PyMem_RawRealloc 
/home/will/python/cpython/Objects/obmalloc.c:84:12
#2 0x8138506 in PyMem_Realloc 
/home/will/python/cpython/Objects/obmalloc.c:343:12
#3 0x8594f1c in tok_nextc 
/home/will/python/cpython/Parser/tokenizer.c:1058:31
#4 0x858e4c9 in tok_get /home/will/python/cpython/Parser/tokenizer.c:1354:17
#5 0x858e1da in PyTokenizer_Get 
/home/will/python/cpython/Parser/tokenizer.c:1804:18
#6 0x85899a7 in parsetok /home/will/python/cpython/Parser/parsetok.c:208:16
#7 0x858b301 in PyParser_ParseFileObject 
/home/will/python/cpython/Parser/parsetok.c:134:12
#8 0x8439e0b in PyParser_ASTFromFileObject 
/home/will/python/cpython/Python/pythonrun.c:1150:15
#9 0x843aa37 in PyRun_FileExFlags 
/home/will/python/cpython/Python/pythonrun.c:916:11
#10 0x8438a98 in PyRun_SimpleFileExFlags 
/home/will/python/cpython/Python/pythonrun.c:396:13
#11 0x84382a6 in PyRun_AnyFileExFlags 
/home/will/python/cpython/Python/pythonrun.c:80:16
#12 0x813f194 in run_file /home/will/python/cpython/Modules/main.c:318:11
#13 0x813f194 in Py_Main /home/will/python/cpython/Modules/main.c:768
#14 0x8138070 in main /home/will/python/cpython/./Programs/python.c:69:11
#15 0xf7558496 in __libc_start_main (/usr/lib32/libc.so.6+0x18496)

SUMMARY: AddressSanitizer: heap-use-after-free 
(/home/will/python/cpython/python+0x80ad09d) in strncpy
Shadow bytes around the buggy address:
  0x3e4e1dd0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x3e4e1de0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x3e4e1df0: fa fa fa fa fa 

[issue26001] Tutorial: write() does not expect string in binary mode

2016-01-03 Thread Dimitri Papadopoulos Orfanos

New submission from Dimitri Papadopoulos Orfanos:

About section "7.2.1. Methods of File Objects" of the tutorial:


1. Method read() is documented as follows:
reads some quantity of data and returns it as a string or bytes object.

Indeed read() returns a string in text mode and bytes in binary mode. For the 
sake of clarity, I suggest changing to:

reads some quantity of data and returns it as a string (in text mode) or bytes 
object (in binary mode).

This might seem long-winded but I believe it would help those moving from 
Python 2 to Python 3.


2. Method write() is documented as follows:

To write something other than a string, it needs to be converted to a string 
first

While this is correct in text mode, it is wrong in binary mode. May I suggest:

To write something other than a string (in text mode) or bytes object (in 
binary mode), it needs to be converted first

--
assignee: docs@python
components: Documentation
messages: 257418
nosy: Dimitri Papadopoulos Orfanos, docs@python
priority: normal
severity: normal
status: open
title: Tutorial: write() does not expect string in binary mode
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



[issue25999] Add support of native number in bin()

2016-01-03 Thread Larry Hastings

Larry Hastings added the comment:

Even if this was a good idea, it's too late to change the behavior of the 
builtin function.

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



[issue26002] make statistics.median_grouped more efficient

2016-01-03 Thread SilentGhost

Changes by SilentGhost :


--
nosy: +steven.daprano
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



[issue25999] Add support of native number in bin()

2016-01-03 Thread SonokoMizuki

SonokoMizuki added the comment:

That's right. currently python can not  distinguish positive number or negative 
number.

>>> a = bin(-5,10)
>>> int(a,2)
1019

I think reason of  ambiguity is decode function( int() ). 
So, I suggest new decode function.
(example) 
>>> b2i('0b1011',negative=True)
-5
>>> b2i('0b1011',negative=False)
11

( I do not know whether it is good to add special function for binary..., sorry)

--

___
Python tracker 

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



[issue26003] Issues with PyEval_InitThreads and PyGILState_Ensure

2016-01-03 Thread tzickel

New submission from tzickel:

A few issues regarding threads:
A. (Python 2 & 3) The documentation (https://docs.python.org/3/c-api/init.html) 
about initializing the GIL/Threading system does not specify that calling 
PyEval_InitThreads actually binds the calling thread as the main_thread in the 
ceval.c, meaning that the thread will be in charge till the process goes down 
for handling Py_AddPendingCall calls, and if it ends/dies, they won't be 
handled anymore.

This ceval.c's main_thread is different BTW from the one in signalmodule.c 
which is bound to the thread that called Py_InitializeEx.

Maybe there is sense for both main_thread to be the same one and initialized in 
the same time ? (even without a GIL existing)

B. (Python 3) Besides the bad documentation regarding this, python 3.4 added 
issue #19576 which actually hides the call for PyEval_InitThreads inside 
PyGILState_Ensure. Without careful care and knowledge by the programmer, this 
might cause for a short lived thread created in C to actually bind the 
ceval.c's main_thread and when the thread dies main_thread will never be 
changed again.

The reason this is important is beforehand, the programmer needed to think 
about PyEval_InitThreads now it's hidden and not even mentioned in the 
documentation.

C. (Python 2 & 3) In PyEval_InitThreads documentation it's written "It is not 
safe to call this function when it is unknown which thread (if any) currently 
has the global interpreter lock." Thus it should be mentioned that 
PyGILState_Ensure is now calling it in the documentation ?

Also I believe the reason this quote exists is because a potential race 
condition between thread A which might be running code in PyEval_EvalFrameEx 
(before PyEval_InitThreads is called, and thus is not GIL aware), and thread B 
which calls PyEval_InitThreads then calls PyGILState_Ensure, then running 
Python code, while thread A is still running python code as well. I think it 
should be explained more clearly in the documentation the implications (race 
condition).

I think there might be a way to make an PyEval_InitThreads variant which can 
overcome this race condition. Basically it involves using Py_AddPendingCall to 
a C function which calls PyEval_InitThreads, and notifies the calling 
command/thread when it's done. This way we can be sure that the GIL is taken by 
one thread, and all the others are blocked. (maybe a signal should be sent as 
well, in case the main_thread is blocked on an I/O operation).

D. (Python 2) If the main_thread finishes it's job, while other python threads 
are still alive, signal handling isn't processed anymore (Example will be added 
as a file).

--
components: Interpreter Core
files: signalexample.py
messages: 257425
nosy: tzickel
priority: normal
severity: normal
status: open
title: Issues with PyEval_InitThreads and PyGILState_Ensure
versions: Python 2.7, Python 3.6
Added file: http://bugs.python.org/file41485/signalexample.py

___
Python tracker 

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



[issue19576] "Non-Python created threads" documentation doesn't mention PyEval_InitThreads()

2016-01-03 Thread tzickel

tzickel added the comment:

I think that the document regarding PyGILState_Ensure and PyEval_InitThreads 
should be clarified better, written in issue #26003

--
nosy: +tzickel

___
Python tracker 

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



[issue26003] Issues with PyEval_InitThreads and PyGILState_Ensure

2016-01-03 Thread tzickel

Changes by tzickel :


--
nosy: +pitrou

___
Python tracker 

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



[issue25083] Python can sometimes create incorrect .pyc files

2016-01-03 Thread tzickel

Changes by tzickel :


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue25596] regular files handled as directories in the glob module

2016-01-03 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

> os.scandir() is called recursively in the last patch and the file descriptors 
> are not closed until returning from the recursion.

No, os.scandir() is called non-recursively in _iterdir(), and since _iterdir() 
results are always accumulated in a list, a recursion starts only after 
exhausting the os.scandir() iterator and closing the file descriptor. We need 
first to resolve issue25994 to close the file descriptor explicitly.

> The glob functions should fail explicitly when scandir() raises OSERROR with 
> posix errno set to EMFILE (The process has too many files open), or even 
> better, silently ignore only the PermissionError exception instead of 
> ignoring OSERROR.

Patched code passes existing tests. Do you have additional tests?

> Is the call to entry.is_symlink() in _iterdir() necessary since is_dir() 
> follows symlinks ?

Ah, I thought is_dir() doesn't follow symlinks. Yes, now the call to 
entry.is_symlink() is not necessary.

> If _iterdir() would yield the DirEntry instance instead of DirEntry.name, 
> then _rlistdir() could use x.is_dir() to know whether it is correct to 
> iterate over _rlistdir(x.path, dironly)

Yes, but this can complicate the rest of the code. _rlistdir() is called with 
dironly=False only when the pattern ends with '**'. I'm not sure this is enough 
important case for optimization. In most cases '**' is used in the middle of 
the pattern, and all names yielded by _iterdir() are directory names (or broken 
symlinks).

--

___
Python tracker 

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