[issue29959] re.match failed to match left square brackets as the first char

2017-04-01 Thread bo qu

New submission from bo qu:

if "[" is the first char in a string, then re.match can't match any pattern 
from the string, but re.findall works fine

details as follows:

[da@namenode log]$ python3
Python 3.4.3 (default, Jun 14 2015, 14:23:40) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> cyzd="[abc]"
>>> cyzd
'[abc]'
>>> pattern="ab(.*)"
>>> pattern
'ab(.*)'
>>> match=re.match(pattern, cyzd)
>>> match
>>> pattern=r'ab(.*)' 
>>> re.findall(pattern, cyzd)
['c]']

--
components: Regular Expressions
messages: 290968
nosy: bo qu, ezio.melotti, mrabarnett
priority: normal
severity: normal
status: open
title: re.match failed to match left square brackets as the first char
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



[issue29959] re.match failed to match left square brackets as the first char

2017-04-01 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

re.match() checks if the beginning of the string matches the regular expression 
pattern. Use re.search() if you want to find the match not at the beginning of 
the string.

https://docs.python.org/3/library/re.html#re.match
https://docs.python.org/3/library/re.html#re.search

--
nosy: +serhiy.storchaka
resolution:  -> not a bug
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



[issue29949] sizeof set after set_merge() is doubled from 3.5

2017-04-01 Thread INADA Naoki

INADA Naoki added the comment:


New changeset e82cf8675bacd7a03de508ed11865fc2701dcef5 by INADA Naoki in branch 
'master':
bpo-29949: Fix set memory usage regression (GH-943)
https://github.com/python/cpython/commit/e82cf8675bacd7a03de508ed11865fc2701dcef5


--

___
Python tracker 

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



[issue29949] sizeof set after set_merge() is doubled from 3.5

2017-04-01 Thread INADA Naoki

Changes by INADA Naoki :


--
pull_requests: +1127

___
Python tracker 

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



[issue29955] logging decimal point should come from locale

2017-04-01 Thread Vinay Sajip

Vinay Sajip added the comment:

I would prefer to keep things as they are - which is conforming to the 
preferences expressed in ISO 8601, and preserving backwards compatibility. I 
agree that a period has some advantages, but I went with what the standard said 
as closely as I could. I'm not sure it has ever been a problem in practice - I 
don't remember any other issue raising it, and this functionality has been the 
same since around 2003 IIRC.

--

___
Python tracker 

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



[issue29943] PySlice_GetIndicesEx change broke ABI in 3.5 and 3.6 branches

2017-04-01 Thread Miro Hrončok

Changes by Miro Hrončok :


--
nosy: +hroncok

___
Python tracker 

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



[issue29954] multiprocessing.Pool.__exit__() calls terminate() instead of close()

2017-04-01 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I agree it's far too late.  Multiple existing libraries may rely on the current 
behaviour.

--
nosy: +pitrou
resolution:  -> wont fix
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



[issue29782] Use __builtin_clzl for bits_in_digit if available

2017-04-01 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I don't think a 3% improvement on a micro-benchmark is worth it (this will 
translate into 0% improvement on real-world workloads).  Are there other uses 
of _Py_bit_length() that show bigger benefits?

--
nosy: +pitrou

___
Python tracker 

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



[issue28157] Document time module constants (timezone, tzname, etc.) as deprecated.

2017-04-01 Thread Cheryl Sabella

Cheryl Sabella added the comment:

The datetime module has a separate section for strptime and strftime.  Any 
interest in splitting those functions into their own section?

--

___
Python tracker 

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



[issue28157] Document time module constants (timezone, tzname, etc.) as deprecated.

2017-04-01 Thread Cheryl Sabella

Cheryl Sabella added the comment:

Also, back to the original title of saying timezone, altzone, etc are 
deprecated - there are examples in the datetime docs that use those constants.  
Should that be updated to tm_zone and tm_gmtoff?

--

___
Python tracker 

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



[issue29947] In SocketServer, why not passing a factory instance for the RequestHandlerClass instead of the class itself?

2017-04-01 Thread Dominic Mayers

Dominic Mayers added the comment:

Perhaps I should raise a separate issue, but it is related, because the current 
code "requires" that we define an handler class with `setup()`, `handle()` and 
`finish()` in its API. If you look at the actual code, there is no such 
requirement. We only have to pass a factory method that receives three 
arguments, creates a new handler instance and starts it. The handler does not 
have to offer any API - you don't even have to subclass the RequestHandlerBase 
class. I still say that it "requires" it, because it is part of the 
documentation and, if you don't, you could be in trouble in future versions. 
However, this requirement is clearly annoying, because if you have an handler 
for another server, you need to re-factorize the code to provide this API, 
which is not even used. I am sure there is no such requirement, but it's not 
clear at first. 

This is clearly not just a documentation issue. The intent in the code is the 
concern of the designers of the code. David and I assume that the intent is 
that we can provide any arbitrary factory method that receives the three 
arguments, creates and starts the handler, but we can be mistaken. In fact, to 
me this looks as a hack, especially given the parameter name, which says that 
we must pass the handler class. An handler class is indeed a factory method, 
but it is a very specific one, not the one that we want to pass if we must 
include extra parameters.

--

___
Python tracker 

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



[issue29960] _random.Random state corrupted on exception

2017-04-01 Thread Bryan G. Olson

New submission from Bryan G. Olson:

Demo:

Run the Python library's test_random.py under the Python debugger and check the
generator at the start of test_shuffle():

C:\bin\Python36>python -m pdb Lib\test\test_random.py
> c:\bin\python36\lib\test\test_random.py(1)()
-> import unittest
(Pdb) break 61
Breakpoint 1 at c:\bin\python36\lib\test\test_random.py:61
(Pdb) continue
.> 
c:\bin\python36\lib\test\test_random.py(61)test_shuffle()
-> shuffle = self.gen.shuffle
(Pdb) list
 56 # randomness source is not available.
 57 urandom_mock.side_effect = NotImplementedError
 58 self.test_seedargs()
 59
 60 def test_shuffle(self):
 61 B-> shuffle = self.gen.shuffle
 62 lst = []
 63 shuffle(lst)
 64 self.assertEqual(lst, [])
 65 lst = [37]
 66 shuffle(lst)
(Pdb) p self.gen.getrandbits(31)
2137781566
(Pdb) p self.gen.getrandbits(31)
2137781566
(Pdb) p self.gen.getrandbits(31)
2137781566
(Pdb) p self.gen.getrandbits(31)
2137781566
(Pdb) p self.gen.getrandbits(31)
2137781566

That's not random.


Diagnosis:

The order in which test functions run is the lexicographic order of their 
names. Thus unittest ran test_setstate_middle_arg() before running 
test_shuffle(). test_setstate_middle_arg() did some failed calls to 
_random.Random.setstate(), which raised exceptions as planned, but also trashed 
the state of the generator. test_random.py continues to use the same instance 
of _random.Random after setstate() raises exceptions.

The documentation for Random.setstate() does not specify what happens to the 
state of the generator if setstate() raises an exception. Fortunately the 
generator recommended for secure applications, SystemRandom, does not implement 
setstate(). 


Solution:

The fix I prefer is a small change to random_setstate() in _randommodule.c, so 
that it does not change the state of the generator until the operation is sure 
to succeed.

--
components: Library (Lib)
messages: 290977
nosy: bryangeneolson
priority: normal
severity: normal
status: open
title: _random.Random state corrupted on exception
type: behavior
versions: Python 3.7

___
Python tracker 

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



[issue29956] math.exp documentation is misleading

2017-04-01 Thread Mark Dickinson

Mark Dickinson added the comment:

> I suggest changing the main docs to match the existing docstring, "Return e 
> raised to the power of x."  

+1 for this description.

--

___
Python tracker 

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



[issue29960] _random.Random state corrupted on exception

2017-04-01 Thread Bryan G. Olson

Bryan G. Olson added the comment:

I'm going through https://docs.python.org/devguide/pullrequest.html and would 
like to be assigned this issue.

--

___
Python tracker 

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



[issue29961] More compact sets and frozensets created from sets

2017-04-01 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

For now new set and frozenset objects can allocate 2 times larger table than 
necessary when are created from set or dict. For example if the size n of the 
original set is the power of two, resulting set will allocate the table of 4*n 
rather that 2*n. Up to 20% of new sets use twice more memory than necessary.

Proposed patch makes set_merge() allocating the table of size n*5/3 instead of 
n*2. This is the minimal size necessary for inserting all elements with fill 
ration <=60%.

$ ./python -c 'N = 6000; from sys import getsizeof; s = 
[getsizeof(frozenset(set(range(n for n in range(N)]; print( [(n, s[n]) for 
n in range(N) if not n or s[n] != s[n-1]] )'
Unpatched:  [(0, 112), (5, 240), (8, 368), (16, 624), (32, 1136), (64, 2160), 
(128, 4208), (256, 8304), (512, 16496), (1024, 32880), (2048, 65648), (4096, 
131184)]
Patched:[(0, 112), (5, 240), (9, 368), (19, 624), (38, 1136), (77, 2160), 
(153, 4208), (307, 8304), (614, 16496), (1229, 32880), (2457, 65648), (4915, 
131184)]

--
components: Interpreter Core
messages: 290980
nosy: inada.naoki, rhettinger, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: More compact sets and frozensets created from sets
type: resource usage
versions: Python 3.7

___
Python tracker 

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



[issue29949] sizeof set after set_merge() is doubled from 3.5

2017-04-01 Thread INADA Naoki

Changes by INADA Naoki :


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



[issue29961] More compact sets and frozensets created from sets

2017-04-01 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
pull_requests: +1128

___
Python tracker 

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



[issue29960] _random.Random state corrupted on exception

2017-04-01 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +mark.dickinson, rhettinger
stage:  -> needs patch

___
Python tracker 

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



[issue29751] PyLong_FromString documentation wrong on numbers with leading zero and base=0

2017-04-01 Thread Cheryl Sabella

Cheryl Sabella added the comment:

Thank you.  I've added that change.

For the backporting, I think that would only be applicable to 3.6 and 3.7?

--

___
Python tracker 

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



[issue29725] sqlite3.Cursor doesn't properly document "arraysize"

2017-04-01 Thread Cheryl Sabella

Changes by Cheryl Sabella :


--
pull_requests: +1129

___
Python tracker 

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



[issue29725] sqlite3.Cursor doesn't properly document "arraysize"

2017-04-01 Thread Cheryl Sabella

Cheryl Sabella added the comment:

Thank you so much for being patient with me and explaining that.

--

___
Python tracker 

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



[issue28157] Document time module constants (timezone, tzname, etc.) as deprecated.

2017-04-01 Thread Cheryl Sabella

Cheryl Sabella added the comment:

I think I may need to apologize.  I'm new to this and was looking through the 
open docs issues and saw this one.  Just now, I noticed that the 'assigned to' 
was filled in.  I had only been looking at tickets that didn't have a pull 
request and not looking at the other values.  I am so sorry if I started 
working on this when I shouldn't have and if I've caused more problems instead 
of helping.

--

___
Python tracker 

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



[issue26947] Documentation improvement needed

2017-04-01 Thread Cheryl Sabella

Changes by Cheryl Sabella :


--
pull_requests: +1130

___
Python tracker 

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



[issue29692] contextlib.contextmanager may incorrectly unchain RuntimeError

2017-04-01 Thread svelankar

Changes by svelankar :


--
pull_requests: +1131

___
Python tracker 

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



[issue29949] sizeof set after set_merge() is doubled from 3.5

2017-04-01 Thread INADA Naoki

INADA Naoki added the comment:


New changeset efde51ad54c58353f25ff80c8d30dbee82ef33a3 by INADA Naoki in branch 
'3.6':
bpo-29949: Fix set memory usage regression (GH-945)
https://github.com/python/cpython/commit/efde51ad54c58353f25ff80c8d30dbee82ef33a3


--

___
Python tracker 

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



[issue29962] Add math.remainder operation

2017-04-01 Thread Mark Dickinson

New submission from Mark Dickinson:

IEEE 754, the C99 standard, the Decimal IBM standard and Java all 
support/specify a 'remainder-near' operation. Apart from being standard, this 
has a number of useful applications:

1. Argument reduction in numerical algorithms: it's common to want to reduce to 
a range [-modulus/2, modulus/2] rather than [0, modulus).
2. Particular case of the above: reduction of angles to lie in the range [-pi, 
pi]
3. Rounding a float x to the nearest multiple of y. This is a much-asked 
StackOverflow question, and the standard answer of y * round(x / y) risks 
introducing floating-point error and so can give incorrect results in corner 
cases. With a remainder operation, it's trivial to do this correctly: x - 
remainder(x, y) gives the closest representable float to the closest integer 
multiple of y to x.

remainder(x, y) has some nice properties: it's *always* exactly representable 
(unlike x % y), it satisfies the symmetry remainder(-x, y) == -remainder(x, y), 
and it's periodic with period 2*y.

I have a patch, and will make a PR shortly.

--
components: Extension Modules
messages: 290985
nosy: mark.dickinson
priority: normal
severity: normal
stage: patch review
status: open
title: Add math.remainder operation
type: enhancement
versions: Python 3.7

___
Python tracker 

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



[issue29962] Add math.remainder operation

2017-04-01 Thread Mark Dickinson

Changes by Mark Dickinson :


--
pull_requests: +1132

___
Python tracker 

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



[issue29956] math.exp documentation is misleading

2017-04-01 Thread Mark Dickinson

Changes by Mark Dickinson :


--
pull_requests: +1133

___
Python tracker 

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



[issue29956] math.exp documentation is misleading

2017-04-01 Thread Mark Dickinson

Mark Dickinson added the comment:

PR made. New wording is:

"""
Return e raised to the power *x*, where e = 2.718281... is the base of natural 
logarithms.
"""

--

___
Python tracker 

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



[issue29962] Add math.remainder operation

2017-04-01 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

See also Decimal.remainder_near and _PyLong_DivmodNear. Shouldn't the new 
function be named math.remainder_near?

In many cases the function that returns the nearest integer quotient is useful. 
See Fraction.__round__, datetime._divide_and_round, _pydecimal._div_nearest, 
etc.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue29962] Add math.remainder operation

2017-04-01 Thread Mark Dickinson

Mark Dickinson added the comment:

> Shouldn't the new function be named math.remainder_near?

Not clear. :-) I'd prefer to keep the name that's consistent with both C and 
IEEE 754. (We already have plenty of naming differences between Decimal and 
math; attempting to reconcile them is likely futile.)

FTR:

IEEE 754: remainder
C99: remainder
IBM Decimal spec: remainder-near
Java: IEEEremainder
.NET: IEEERemainder

--

___
Python tracker 

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



[issue29962] Add math.remainder operation

2017-04-01 Thread Mark Dickinson

Mark Dickinson added the comment:

> In many cases the function that returns the nearest integer quotient is 
> useful.

Agreed, but I'd like to keep the scope of this issue small for now: we're 
simply wrapping / implementing another C99 math.h function.

--

___
Python tracker 

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



[issue29962] Add math.remainder operation

2017-04-01 Thread Mark Dickinson

Mark Dickinson added the comment:

FTR, I don't have strong opinions on the name: I could be persuaded by any of 
`remainder`, `remainder_near` or `ieee_remainder`. I find `ieee_remainder` 
somewhat more informative than `remainder_near`.

--

___
Python tracker 

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



[issue29962] Add math.remainder operation

2017-04-01 Thread Raymond Hettinger

Raymond Hettinger added the comment:

> I'd prefer to keep the name that's consistent with both C and IEEE 754.

+1  

Also, the decimal module names are a poor guide.  Its usability has been 
impaired by opaque naming (i.e. needing to use quantize() when you want to 
round to a fixed number of places).

--
nosy: +rhettinger

___
Python tracker 

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



[issue29960] _random.Random state corrupted on exception

2017-04-01 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee:  -> rhettinger

___
Python tracker 

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



[issue29961] More compact sets and frozensets created from sets

2017-04-01 Thread Raymond Hettinger

Raymond Hettinger added the comment:

FWIW, I've long considered this to be a feature of set and dicts, it is the 
only way a user can affect sparseness.  For lookup only sets, the extra 
sparseness is a virtue (fewer collisions).  So, I would like to leave the 
current code in-place.  

With sets the goals are different from dicts.  I place less value on 
compactness and more value on fast membership testing.  And with dicts, the 
norm is that the looked-up key usually exists.  With sets, the goal isn't 
looking an element known to be in the set, but more about determining whether 
an element is in the set.  Accordingly, sets have to optimize for misses as 
well as hits.

In the future, please assign set feature requests to me so that I don't miss 
them.

--
assignee:  -> rhettinger
resolution:  -> rejected
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



[issue29957] unnecessary LBYL for key contained in defaultdict, lib2to3/btm_matcher

2017-04-01 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Rather than removing the defaultdict, I think a cleaner fix is to just remove 
the unnecessary LBYL.   That leaves the code a little more compact, faster, and 
nice looking.

--

___
Python tracker 

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



[issue23033] Disallow support for a*.example.net, *a.example.net, and a*b.example.net in certificate wildcard handling.

2017-04-01 Thread Raymond Hettinger

Raymond Hettinger added the comment:

+1

--
nosy: +rhettinger

___
Python tracker 

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



[issue29897] itertools.chain behaves strangly when copied with copy.copy

2017-04-01 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Serhiy, feel free to take this in whatever direction you think is best.

--
assignee:  -> serhiy.storchaka

___
Python tracker 

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



[issue29947] In SocketServer, why not passing a factory instance for the RequestHandlerClass instead of the class itself?

2017-04-01 Thread Dominic Mayers

Dominic Mayers added the comment:

To sum up, David clarified that we can in fact easily pass an arbitrary factory 
method that creates and starts a request handler, instead of a request handler 
class with setup, handle and finish in its API. This could indeed be a valid 
reason to consider this issue resolved,  but I would like to be sure that it is 
really a normal and supported use of the code. The only place where I can ask 
this is here. If I ask in StackOverflow, etc. I would get all kind of opinions  
and it would not be useful.  To be honest, looking at the parameter name, the 
documentation,  the examples, etc. it does not look at all a normal and 
supported use of the code, but who am I to decide that?  If it turns out to be 
a normal and supported use of the code, then I will create a different issue 
only about the documentation, because it's not clear at all.

--
nosy: +martin.panter

___
Python tracker 

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



[issue29961] More compact sets and frozensets created from sets

2017-04-01 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

There is a program that uses 32 GB for sets. The patch could save up to 6 GB 
for it.

I understood your arguments when you lowered the maximal fill ration from 2/3 
to 60%. But in that case the fill ratio is between 15% and 30%! Isn't it too 
small?

--

___
Python tracker 

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



[issue29957] unnecessary LBYL for key contained in defaultdict, lib2to3/btm_matcher

2017-04-01 Thread Michael Selik

Michael Selik added the comment:

Ok, I'll change the PR.

--

___
Python tracker 

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



[issue28157] Document time module constants (timezone, tzname, etc.) as deprecated.

2017-04-01 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

Cheryl,

There is no need to apologize. I assigned this issue to myself when I created 
it because I had a few ideas about refactoring the time module documentation 
and thought I would get to it soon.  As often happens other priorities 
interfered.

Contributions are welcome regardless of the "Assigned To" status on the issue.  
In fact, assigned issues may get a quicker response from the assignee than 
unassigned ones.

When looking for simple issues to work on, look for an "easy" keyword.  I did 
not mark this issue as "easy" because I planned to rearrange the module 
documentation in addition to adding a deprecation note.

--
keywords: +3.2regression

___
Python tracker 

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



[issue28157] Document time module constants (timezone, tzname, etc.) as deprecated.

2017-04-01 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

> The datetime module ..

Yes, the datetime module documentation can be improved, but let's keep this 
issue focused on the time module.  Please open a new issue for the datetime 
module improvements.

--

___
Python tracker 

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



[issue28157] Document time module constants (timezone, tzname, etc.) as deprecated.

2017-04-01 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
keywords:  -3.2regression

___
Python tracker 

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



[issue5906] Risk of confusion in multiprocessing module - daemonic processes

2017-04-01 Thread Tim Peters

Tim Peters added the comment:

I'll take a crack at these ancient comments ;-)

"""
daemon
The process’s daemon flag, a Boolean value. This must be set before start() 
is called.
The initial value is inherited from the creating process. [1]
When a process exits, it attempts to terminate all of its daemonic child 
processes. [2]

[1] this sentence is weird: since daemonic processes are not allowed to have 
children, isn't this flag always False in a new Process instance ?
"""

Yes.  I agree it's confusing; looks like it was pasted from the `threading` 
docs a long time ago, in which context it had a non-degenerate meaning.

I've personally found this `multiprocessing` restriction (daemonic processes 
can't have children) to be nothing but a pain in the ass, especially since 
`Pool` worker processes are (although this doesn't appear to be documented) 
created as daemonic processes.  (Note that 
`concurrent.futures.ProcessPoolExecutor` doesn't have this restriction.)

"""
[2] typo, it meant "all of its NON-daemonic child processes" instead, didn't it 
?
"""

No, this was correct.  When a process exits, it waits to join its non-daemonic 
children, but brutally terminates its daemonic children midstream.  For 
example, run this:

import multiprocessing as mp
from time import sleep

def e(tag):
for i in range(10):
print(tag, i)
sleep(1)

if __name__ == '__main__':
p = mp.Process(target=e, args=("daemon",), daemon=True)
q = mp.Process(target=e, args=("normal",))
p.start()
q.start()
sleep(5)

You'll see that, after 5 seconds, the main process exits and terminates the 
daemonic process immediately, but waits for the non-daemonic process to finish:

daemon 0
normal 0
daemon 1
normal 1
daemon 2
normal 2
daemon 3
normal 3
daemon 4
normal 4
normal 5
normal 6
normal 7
normal 8
normal 9

--
nosy: +tim.peters

___
Python tracker 

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



[issue28157] Document time module constants (timezone, tzname, etc.) as deprecated.

2017-04-01 Thread Cheryl Sabella

Changes by Cheryl Sabella :


--
pull_requests: +1134

___
Python tracker 

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



[issue29339] Interactive: Move to same indentation level as previousline

2017-04-01 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
resolution:  -> rejected
stage: needs patch -> 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



[issue29947] In SocketServer, why not passing a factory instance for the RequestHandlerClass instead of the class itself?

2017-04-01 Thread R. David Murray

R. David Murray added the comment:

Well, we could document it as a factory argument, and explain that the argument 
name is an historical artifact.

--

___
Python tracker 

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



[issue29162] pyshell.py: name 'sys' is not defined

2017-04-01 Thread Terry J. Reedy

Terry J. Reedy added the comment:

The follow-up tkinter import issue is #29446

--

___
Python tracker 

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



[issue29947] In SocketServer, why not passing a factory instance for the RequestHandlerClass instead of the class itself?

2017-04-01 Thread R. David Murray

R. David Murray added the comment:

Given how old socket server is, and that it doesn't actually require that API, 
we should probably just reword the documentation so that it is clear that 
RequestHandlerClass is the default Handler implementation (and that you can 
work with setup/handle/finish if you want to subclass it), and document what 
the *actual* requirements on the Handler are.  

We are unlikely to change socketserver's actual API at this point.

I don't think there's any need for a new issue, let's just make this a 
documentation issue.  The original title still even applies :)  We will need 
signoff from someone with more direct interest in the socketserver module than 
me, but given that the "future" for the stuff socketserver handles is asyncio, 
I suspect the only objection we might get is "it's not worth it".  But if 
someone wants to do the work, *I* don't see a reason to reject it.

--
assignee:  -> docs@python
components: +Documentation
nosy: +docs@python
stage: resolved -> 
type: enhancement -> behavior
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



[issue29960] _random.Random state corrupted on exception

2017-04-01 Thread Bryan G. Olson

Changes by Bryan G. Olson :


--
pull_requests: +1135

___
Python tracker 

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



[issue29763] test_site failing on AppVeyor

2017-04-01 Thread Zachary Ware

Changes by Zachary Ware :


--
pull_requests: +1136

___
Python tracker 

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



[issue29947] In SocketServer, why not passing a factory instance for the RequestHandlerClass instead of the class itself?

2017-04-01 Thread Dominic Mayers

Dominic Mayers added the comment:

The reason why I feel we should not make it immediately a documentation issue 
is that I don't know how a person working on documentation could proceed ahead 
without a clear go ahead signal from developers. In that sense,  having a 
documentation that says that the variable name does not reflect its intent 
seems tricky. It's very easy to change a variable name. It cannot possibly 
break the code, except for a collision, but they are easy to avoid.  If we 
don't have the interest of developers, not even for a simple renaming, I don't 
see a go ahead signal in this.

--

___
Python tracker 

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



[issue29947] In SocketServer, why not passing a factory instance for the RequestHandlerClass instead of the class itself?

2017-04-01 Thread Dominic Mayers

Dominic Mayers added the comment:

Oops, I did not realize that David was one of the developers. Well, may be this 
needs the attention of more than one developer.

--

___
Python tracker 

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



[issue26947] Hashable documentation improvement needed

2017-04-01 Thread Martin Panter

Martin Panter added the comment:

The pull request currently suggests “All of Python’s immutable built-in objects 
are hashable; mutable containers (such as lists or dictionaries) are not.” This 
seems better wording than the original.

FWIW, I would have tried “Python’s built-in immutable objects are hashable, 
while mutable containers (such as lists and dictionaries) are not hashable.”

--
nosy: +martin.panter
title: Documentation improvement needed -> Hashable documentation improvement 
needed

___
Python tracker 

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



[issue29941] Confusion between asserts and Py_DEBUG

2017-04-01 Thread Thomas Wouters

Changes by Thomas Wouters :


--
pull_requests: +1137

___
Python tracker 

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



[issue29941] Confusion between asserts and Py_DEBUG

2017-04-01 Thread Thomas Wouters

Changes by Thomas Wouters :


--
pull_requests: +1138

___
Python tracker 

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



[issue5906] Risk of confusion in multiprocessing module - daemonic processes

2017-04-01 Thread Eryk Sun

Eryk Sun added the comment:

> I've personally found this `multiprocessing` restriction (daemonic 
> processes can't have children) to be nothing but a pain in the ass 

To make that reliable on Windows you could create a silent-breakaway, 
kill-on-close Job object in each process for its daemon children. Closing the 
job handle would cascade terminate all descendant daemon processes in that 
branch of the process tree, i.e. when a process is terminated it closes the Job 
handle, which terminates all of its daemon children, which closes their Job 
handles, which terminates all of their daemon children, and so on. Non-daemons 
would still be orphaned when the parent is terminated.

--
nosy: +eryksun

___
Python tracker 

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



[issue5906] Risk of confusion in multiprocessing module - daemonic processes

2017-04-01 Thread Tim Peters

Tim Peters added the comment:

@Eryk, not me ;-)  I find the "daemonic or not?" distinction useless for 
processes - it just gets in the way at times (e.g., a Pool worker dies with an 
assert(!) error if it tries to create its own Pool for something).

I don't care about orphans either.

It's one reason `concurrent.futures.ProcessPoolExecutor` is sometimes more 
attractive (it has no "daemon" concept, the processes it creates don't vanish 
midstream at sometimes surprising times, and neither do they refuse to create 
additional cf process pools).

--

___
Python tracker 

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



[issue5906] Risk of confusion in multiprocessing module - daemonic processes

2017-04-01 Thread Eryk Sun

Eryk Sun added the comment:

> e.g., a Pool worker dies with an assert(!) error if it tries to create 
> its own Pool for something

A daemon process could create a child daemon when the OS can ensure that no 
orphans are left behind (e.g. call Linux prctl to set PR_SET_PDEATHSIG as 
SIGKILL). This would allow a pool worker to create another process pool.

--

___
Python tracker 

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



[issue26947] Hashable documentation improvement needed

2017-04-01 Thread Senthil Kumaran

Senthil Kumaran added the comment:


New changeset 64c887ab3a400cf91bde4f0c5ef69eacc88bc5e1 by Senthil Kumaran 
(csabella) in branch 'master':
bpo-26947: DOC: clarify wording on hashable in glossary (#948)
https://github.com/python/cpython/commit/64c887ab3a400cf91bde4f0c5ef69eacc88bc5e1


--
nosy: +orsenthil

___
Python tracker 

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



[issue26947] Hashable documentation improvement needed

2017-04-01 Thread Senthil Kumaran

Changes by Senthil Kumaran :


--
pull_requests: +1139

___
Python tracker 

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



[issue26947] Hashable documentation improvement needed

2017-04-01 Thread Senthil Kumaran

Changes by Senthil Kumaran :


--
pull_requests: +1140

___
Python tracker 

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



[issue26947] Hashable documentation improvement needed

2017-04-01 Thread Senthil Kumaran

Senthil Kumaran added the comment:


New changeset 51fc7e3d6a29de7b3142e51f8caf4d31f7ac72a0 by Senthil Kumaran in 
branch '3.5':
bpo-26947: DOC: clarify wording on hashable in glossary (#948) (#958)
https://github.com/python/cpython/commit/51fc7e3d6a29de7b3142e51f8caf4d31f7ac72a0


--

___
Python tracker 

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



[issue26947] Hashable documentation improvement needed

2017-04-01 Thread Senthil Kumaran

Senthil Kumaran added the comment:


New changeset a71a3ad54d14483cfaebd8e0fb96c97c798d9e32 by Senthil Kumaran in 
branch '3.6':
bpo-26947: DOC: clarify wording on hashable in glossary (#948) (#957)
https://github.com/python/cpython/commit/a71a3ad54d14483cfaebd8e0fb96c97c798d9e32


--

___
Python tracker 

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



[issue26947] Hashable documentation improvement needed

2017-04-01 Thread Senthil Kumaran

Changes by Senthil Kumaran :


--
resolution:  -> fixed
stage:  -> resolved
status: open -> closed
type:  -> behavior

___
Python tracker 

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



[issue5906] Risk of confusion in multiprocessing module - daemonic processes

2017-04-01 Thread Tim Peters

Tim Peters added the comment:

Again, I don't care about orphans.  In the usual cases people are running code 
with no concern about what happens in case of forced termination.  The only 
thing stopping it now is that the code goes out of its way to prevent it (or, 
alternatively, goes out of its way to force Pool workers to be daemonic).  So, 
e.g., people publish recipes for replacing multiprocessing.Pool to remove this 
restriction, like here:

http://stackoverflow.com/questions/6974695/python-process-pool-non-daemonic/8963618#8963618

--

___
Python tracker 

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



[issue26947] Hashable documentation improvement needed

2017-04-01 Thread Senthil Kumaran

Senthil Kumaran added the comment:

I reviewed in the pull request. I agree that the wording was slightly better 
than the original.

--

___
Python tracker 

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



[issue26947] Hashable documentation improvement needed

2017-04-01 Thread Senthil Kumaran

Senthil Kumaran added the comment:

I have to admit, I did not see some of the negative votes in this ticket before 
merging the patch. If your is opposition is strong,  please comment and suggest 
a better improvement over the patch. thank you!

--

___
Python tracker 

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



[issue29941] Confusion between asserts and Py_DEBUG

2017-04-01 Thread Thomas Wouters

Thomas Wouters added the comment:


New changeset 90e3518225bafaff01469ed48c472ae7db5686f0 by T. Wouters in branch 
'3.6':
bpo-29941: Assert fixes (#886) (#955)
https://github.com/python/cpython/commit/90e3518225bafaff01469ed48c472ae7db5686f0


--

___
Python tracker 

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



[issue29941] Confusion between asserts and Py_DEBUG

2017-04-01 Thread Thomas Wouters

Thomas Wouters added the comment:


New changeset 553275d125478a6563dde7523f4f28c92f1861b4 by T. Wouters in branch 
'3.5':
bpo-29941: Assert fixes (#886) (#956)
https://github.com/python/cpython/commit/553275d125478a6563dde7523f4f28c92f1861b4


--

___
Python tracker 

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



[issue29751] PyLong_FromString documentation wrong on numbers with leading zero and base=0

2017-04-01 Thread Martin Panter

Martin Panter added the comment:

Underscores are only applicable to 3.6+, but the original concern about leading 
zeros applies to 3.5.

On Git Hub I suggested dropping the details and just referring to the Lexical 
Analysis section 
 
for the details.

FWIW here is my understanding of integer literals (with base=0):

* 0x10 => hexadecimal
* 0b10 => binary
* 0o10 => octal (corresponds to 010 in Python 2)
* 01 => illegal (avoids conflict with Python 2)
* 00 => zero (special case; was treated as octal zero in Python 2)
* 10 => decimal (must not start with digit 0)

If you want to spell out the rules, in my mind there are four special prefixes, 
0x, 0b, 0o and 0, and the default is decimal if none of those prefixes apply.

--

___
Python tracker 

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



[issue29961] More compact sets and frozensets created from sets

2017-04-01 Thread INADA Naoki

INADA Naoki added the comment:

I also feel set created from iterator is too large sometimes.
Especially, frozenset is used for "unordered tuple" dict key sometimes.

$ python -c 'N = 6000; from sys import getsizeof; s = 
[getsizeof(frozenset(range(n))) for n in range(N)]; print( [(n, s[n]) for n in 
range(N) if not n or s[n] != s[n-1]] )'
[(0, 224), (5, 736), (21, 2272), (85, 8416), (341, 32992), (1365, 131296), 
(5461, 524512)]

$ python -c 'N = 6000; from sys import getsizeof; s = 
[getsizeof(dict.fromkeys(range(n))) for n in range(N)]; print( [(n, s[n]) for n 
in range(N) if not n or s[n] != s[n-1]] )'
[(0, 240), (6, 368), (11, 648), (22, 1184), (43, 2280), (86, 4704), (171, 
9320), (342, 18528), (683, 36968), (1366, 73824), (2731, 147560), (5462, 
295008)]

set size increases by *4 each resize.
This is code of set_add_entry():

if ((size_t)so->fill*5 < mask*3)
return 0;
return set_table_resize(so, so->used>5 ? so->used*2 : so->used*4);

If we simply replace `so->used>5 ? so->used*2 : so->used*4` with 
`so->used*2`, there may be not enough room when there are some dummy entries. 
(used + dummy = fill).

But how about replacing `*4` with `*3`?
In general, load factor after resize will be changed from 12.5% ~ 25% to 16.6% 
~ 33.3%. It seems OK to me.
In case of no removal (e.g. constructor called with iterator), set size 
increases by *2 each time:

>>> for n in range(3, 20):
... print(math.ceil(2 ** n * 3/5) * 3, 2 ** (n+1))
15 16
30 32
60 64
117 128
231 256
462 512
924 1024
1845 2048
3687 4096
7374 8192
14748 16384
29493 32768
58983 65536
117966 131072
235932 262144
471861 524288
943719 1048576

--

___
Python tracker 

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



[issue29961] More compact sets and frozensets created from sets

2017-04-01 Thread Raymond Hettinger

Raymond Hettinger added the comment:

You guys seem to have an enormous about of spare time and seem to feel to need 
to redesign every single thing you see.  Please slow down and allow me to 
breathe a bit.  I cannot keep up with a new "let's change x" every single day.  
This set object has been a successful design for a very long time.  I like the 
balance that it has struck and do not want to constantly mess with its tuning 
or parameters.

I working on bigger ideas at the moment that will make all of this irrelevant 
but can't make progress with you two proposing micro changes on an almost daily 
basis.

Please pick some actual bugs to go fix or implement a feature request to propel 
the language forward.  Eating up 100% of my development time is crippling my 
ability to contribute.  And I've grown weary of revisiting old ground over and 
over.  Please move on.

--

___
Python tracker 

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



[issue29961] More compact sets and frozensets created from sets

2017-04-01 Thread INADA Naoki

INADA Naoki added the comment:

OK, sorry about bothering you.

--

___
Python tracker 

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



[issue29446] Improve tkinter 'import *' situation

2017-04-01 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
keywords: +easy
stage: test needed -> 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



[issue29961] More compact sets and frozensets created from sets

2017-04-01 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Okay. I was going to provide patches for other set's weirdness (for example a 
set can increase its size after removing elements), but with your reaction I 
see that this doesn't make sense. I wash my hands from fixing set.

--

___
Python tracker 

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



[issue29947] In SocketServer, why not passing a factory instance for the RequestHandlerClass instead of the class itself?

2017-04-01 Thread Martin Panter

Martin Panter added the comment:

By “factory instance”, I presume you just mean a function (or class or method) 
that returns an appropriate object when called. (I think these are normally 
called “factory functions”. Instances are objects, the things that class 
constructors and factories return.)

What is being proposed? The best idea that I understand is hinted in 
. That is, to document and allow 
any function (not just a class or factory) to be passed as (or instead of) the 
RequestHandlerClass parameter.

This is a significant change to the documentation and API, but I would support 
it, and I think it should already be supported by the implementation.

The question of renaming the RequestHandlerClass parameter is a harder decision 
IMO. I think it would be easier to make the documentation clear that it is a 
misnomer and does not have to be a class. But in the long term, renaming the 
parameter seems nicer.

If it was “renamed”, we would first have to add a competing parameter, keep the 
old parameter around, consider adding deprecation warnings in 2020 when Python 
2 is dead, document both parameters, decide if anything should happen when both 
parameters are passed, etc. Much trickier, but possible. This renaming process 
is similar to “base64.encodestring” vs “encodebytes”, but more involved. I 
can’t think of an example where a function or constructor parameter was renamed 
like this.

--

___
Python tracker 

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



[issue29957] unnecessary LBYL for key contained in defaultdict, lib2to3/btm_matcher

2017-04-01 Thread Benjamin Peterson

Benjamin Peterson added the comment:


New changeset 11fa3c7cd1b151e302d4eee0369cafbaf151c8fb by Benjamin Peterson 
(Michael Selik) in branch 'master':
bpo-29957: change LBYL key lookup to dict.setdefault (#938)
https://github.com/python/cpython/commit/11fa3c7cd1b151e302d4eee0369cafbaf151c8fb


--

___
Python tracker 

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



[issue29947] In SocketServer, why not passing a factory instance for the RequestHandlerClass instead of the class itself?

2017-04-01 Thread Dominic Mayers

Dominic Mayers added the comment:

I did not think very far when said that renaming the parameter could not 
possibly break the code ! Oh well ! But, renaming the parameter was not 
important in itself.  It was to make the situation clearer and easier for those 
who write the documentation. Martin mentioned that it is a big change for the 
API. This is what I had in mind. And yes, I should have used 'factory 
function', not 'factory instance'. Oh well ! I am glad things are working and 
that we will move ahead to resolve this issue.

--

___
Python tracker 

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