[issue36490] Modernize function signature format in Archiving section of shutil doc

2019-03-31 Thread Inada Naoki


Inada Naoki  added the comment:

I don' think they are modern-style vs legacy-style.

When explicit default value is present, the default value is documented in 
signature like `param=42`.
On the other hand, when default value is not explicit (just an placeholder), 
the parameter is expressed using optional group `[param]`.

--
nosy: +inada.naoki

___
Python tracker 

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



[issue34160] ElementTree not preserving attribute order

2019-03-31 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Stefan, as the module maintainer, you get to make the final decision on this.  
What you've proposed makes sense in light of the prior discussion and the 
python-dev discussion.  Unless you think something new will come along to 
change your mind, just mark as closed/fixed, then continue work on c14n in 
another tracker issue.

--

___
Python tracker 

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



[issue36466] Adding a way to strip annotations from compiled bytecode

2019-03-31 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

Here are some quick measurements on a single module¹ that uses typing. It shows 
about a 7% space savings between the baseline and patched versions:

  -rw-r--r--  1 raymond  staff  3490 Mar 31 15:07 kmeans.cpython-38.opt-2.pyc
  -rw-r--r--  1 raymond  staff  3245 Mar 31 15:10 kmeans.cpython-38.opt-2.pyc

Since unique types are singletons, the savings will likely be much less on 
bigger modules where the same types are used over and over again in the 
signatures:

>>> List[int] is List[int]
True

It would be nice if someone could measure the effect on a big project. It's 
possible that the benefits are negligible compared the savings from docstrings.

¹ https://raw.githubusercontent.com/rhettinger/modernpython/master/kmeans.py

--

___
Python tracker 

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



[issue36484] Can't reorder TLS 1.3 ciphersuites

2019-03-31 Thread Eman Alashwali


Eman Alashwali  added the comment:

Thanks. Just to clarify regarding your comment: "Applications shouldn't
modify the cipher suites any more.":
I use python to develop scripts for running experiments, which requires me
to simulate specific clients precisely including their TLS 1.3 ciphers
order.
As you know, TLS 1.3 can not have weak ciphers and only 3 or 4 secure ones
are permitted by design. But still the order should be accurate in
simulation experiment settings. This is different from ordinary
development. It is a bit disappointing that the developer can re-order the
weaker ones (in TLS 1.2) but not TLS 1.3.
However, thanks again for your reply.

On Sun, Mar 31, 2019 at 8:46 PM Christian Heimes 
wrote:

>
> Christian Heimes  added the comment:
>
> I don't have plans to implement cipher suite selection for TLS 1.3 any
> time soon, maybe not at all. TLS 1.3 changed cipher selection a lot, making
> the API more complicated. The signature algorithm and key agreement groups
> are handled as separate extensions, resulting in three additional APIs.
>
> Applications shouldn't modify the cipher suites any more. These days TLS
> libraries provide a good and safe selection of suites. Weak ciphers should
> be disabled by either a security update of the TLS library or system-wide
> settings.
>
> There is one workaround: You can influence connection parameters with an
> OpenSSL config file [1][2] by setting OPENSSL_CONF env var. OpenSSL parses
> the file only once, so you have to set it before you start Python.
>
> [1] https://www.openssl.org/docs/manmaster/man5/config.html
> [2] https://fedoraproject.org/wiki/Changes/CryptoPolicy
>
> --
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue36493] Add math.midpoint(a,b) function

2019-03-31 Thread Christian Heimes


Christian Heimes  added the comment:

What's the argument for midpoint(inf, -inf) == 0? This feels wrong to me. I'm 
certainly not an expert on math, but I still remember that there are different 
kinds of infinities. For examples 'n**n' approaches infinity 'faster' than 
'-(2**n)'.

--
nosy: +christian.heimes

___
Python tracker 

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



[issue36484] Can't reorder TLS 1.3 ciphersuites

2019-03-31 Thread Christian Heimes


Christian Heimes  added the comment:

I don't have plans to implement cipher suite selection for TLS 1.3 any time 
soon, maybe not at all. TLS 1.3 changed cipher selection a lot, making the API 
more complicated. The signature algorithm and key agreement groups are handled 
as separate extensions, resulting in three additional APIs.

Applications shouldn't modify the cipher suites any more. These days TLS 
libraries provide a good and safe selection of suites. Weak ciphers should be 
disabled by either a security update of the TLS library or system-wide 
settings. 

There is one workaround: You can influence connection parameters with an 
OpenSSL config file [1][2] by setting OPENSSL_CONF env var. OpenSSL parses the 
file only once, so you have to set it before you start Python.

[1] https://www.openssl.org/docs/manmaster/man5/config.html
[2] https://fedoraproject.org/wiki/Changes/CryptoPolicy

--

___
Python tracker 

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



Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-31 Thread Ian Kelly
On Sun, Mar 31, 2019 at 1:09 PM Alexey Muranov 
wrote:
>
> On dim., Mar 31, 2019 at 6:00 PM, python-list-requ...@python.org wrote:
> > On Sat, Mar 30, 2019, 5:32 AM Alexey Muranov
> > 
> > wrote:
> >
> >>
> >>  On ven., Mar 29, 2019 at 4:51 PM, python-list-requ...@python.org
> >> wrote:
> >>  >
> >>  > There could perhaps be a special case for lambda expressions such
> >>  >  that,
> >>  > when they are directly assigned to a variable, Python would use
> >> the
> >>  > variable name as the function name. I expect this could be
> >>  >  accomplished by
> >>  > a straightforward transformation of the AST, perhaps even by just
> >>  >  replacing
> >>  > the assignment with a def statement.
> >>
> >>  If this will happen, that is, if in Python assigning a
> >> lambda-defined
> >>  function to a variable will mutate the function's attributes, or
> >> else,
> >>  if is some "random" syntactically-determined cases
> >>
> >>  f = ...
> >>
> >>  will stop being the same as evaluating the right-hand side and
> >>  assigning the result to "f" variable, it will be a fairly good extra
> >>  reason for me to go away from Python.
> >>
> >
> > Is there a particular reason you don't like this? It's not too
> > different
> > from the syntactic magic Python already employs to support the
> > 0-argument
> > form of super().
>
> I do not want any magic in a programming language i use, especially if
> it breaks simple rules.
>
> I do not like 0-argument `super()` either, but at least I do not have
> to use it.

Well, you wouldn't have to use my suggestion either, since it only applies
to assignments of the form "f = lambda x: blah". As has already been
stated, the preferred way to do this is with a def statement. So just use a
def statement for this, and it wouldn't affect you (unless you *really*
want the function's name to be "" for some reason).

That said, that's also the reason why this probably wouldn't happen. Why go
to the trouble of fixing people's lambda assignments for them when the
preferred fix would be for them to do it themselves by replacing them with
def statements?

> Neither i like how a function magically turns into a generator if the
> keyword `yield` appears somewhere within its definition.

I agree, there should have been a required syntactic element on the "def"
line as well to signal it immediately to the reader. It won't stop me from
using them, though.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-31 Thread Alexey Muranov

On dim., Mar 31, 2019 at 6:00 PM, python-list-requ...@python.org wrote:
On Sat, Mar 30, 2019, 5:32 AM Alexey Muranov 


wrote:



 On ven., Mar 29, 2019 at 4:51 PM, python-list-requ...@python.org 
wrote:

 >
 > There could perhaps be a special case for lambda expressions such
 >  that,
 > when they are directly assigned to a variable, Python would use 
the

 > variable name as the function name. I expect this could be
 >  accomplished by
 > a straightforward transformation of the AST, perhaps even by just
 >  replacing
 > the assignment with a def statement.

 If this will happen, that is, if in Python assigning a 
lambda-defined
 function to a variable will mutate the function's attributes, or 
else,

 if is some "random" syntactically-determined cases

 f = ...

 will stop being the same as evaluating the right-hand side and
 assigning the result to "f" variable, it will be a fairly good extra
 reason for me to go away from Python.



Is there a particular reason you don't like this? It's not too 
different
from the syntactic magic Python already employs to support the 
0-argument

form of super().


I do not want any magic in a programming language i use, especially if 
it breaks simple rules.


I do not like 0-argument `super()` either, but at least I do not have 
to use it. I am suspicious of `__class__` too. But here only 
identifiers are hacked, not the assignment operator. (I suppose the 
hack can be unhacked by using your own meta-class with a custom 
`__prepare__`.)


Neither i like how a function magically turns into a generator if the 
keyword `yield` appears somewhere within its definition.


Those are the things i don't like the most in Python.

Alexey.


--
https://mail.python.org/mailman/listinfo/python-list


[issue32538] Multiprocessing Manager on 3D list - no change of the list possible

2019-03-31 Thread Berker Peksag


Change by Berker Peksag :


--
components: +Library (Lib) -Interpreter Core

___
Python tracker 

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



[issue32538] Multiprocessing Manager on 3D list - no change of the list possible

2019-03-31 Thread Berker Peksag


Berker Peksag  added the comment:

I'm a bit late to reply, but I think you are using the API wrong. Please try 
the following snippet:

from multiprocessing import Manager

manager = Manager()

data = manager.list([manager.list([manager.list(['', '', '', '', '', '', '', 
'', '', '', '', ''])])])

print(data[0][0])
print(data[0][0][0])
print(data[0][0][1])

data[0][0][0] = 5
data[0][0][1] = '5'

print(data[0][0])
print(data[0][0][0])
print(data[0][0][1])

Output:

$ ./python.exe example.py
['', '', '', '', '', '', '', '', '', '', '', '']


[5, '5', '', '', '', '', '', '', '', '', '', '']
5
5

You can also take a look at the tests in the original commit that implemented 
this feature:

https://github.com/python/cpython/commit/86a76684269f940a20366cb42668f1acb0982dca

--
nosy: +berker.peksag, davin, pitrou
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



[issue36150] Possible assertion failures due to _ctypes.c's PyCData_reduce()

2019-03-31 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue36150] Possible assertion failures due to _ctypes.c's PyCData_reduce()

2019-03-31 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 5e233951d931acc0e927100c51e9a27a2791b6a5 by Serhiy Storchaka 
(Miss Islington (bot)) in branch '3.7':
bpo-36150: Fix possible assertion failures due to _ctypes.c's PyCData_reduce(). 
(GH-12106) (GH-12642)
https://github.com/python/cpython/commit/5e233951d931acc0e927100c51e9a27a2791b6a5


--

___
Python tracker 

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



[issue36150] Possible assertion failures due to _ctypes.c's PyCData_reduce()

2019-03-31 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset a110817c080ca3c2f3262350b5d7e0c0582527e6 by Serhiy Storchaka 
(Zackery Spytz) in branch '2.7':
bpo-36150: Fix possible assertion failures due to _ctypes.c's PyCData_reduce(). 
(GH-12106) (GH-12643)
https://github.com/python/cpython/commit/a110817c080ca3c2f3262350b5d7e0c0582527e6


--

___
Python tracker 

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



[issue36442] Different ValueError for the same operation in List and Tuple

2019-03-31 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Yes, it is. Thank you Karthikeyan!

--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Non-informative error message in index() and remove() functions

___
Python tracker 

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



[issue30587] Mock with spec object does not ensure method call signatures

2019-03-31 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
pull_requests:  -4411

___
Python tracker 

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



[issue30587] Mock with spec object does not ensure method call signatures

2019-03-31 Thread Karthikeyan Singaravelan

Karthikeyan Singaravelan  added the comment:

I am slightly concerned if spec should gain more responsibility than just 
validating attribute access which is mentioned in the docs. With the linked PR 
spec below would also validate the signature which is not done in Python 3.7 so 
this might break code for someone who only wants to validate access attribute 
access and not signature of the methods. It seems the PR also adds autospec 
argument to Mock that is currently not supported though spec and spec_set are 
supported.

from unittest import mock

def foo(lish):
pass

mock_foo = mock.Mock(spec=foo)
mock_foo(1, 2)

try:
mock_foo.non_existent
except AttributeError:
print("raises AttributeError for non-existent attribute")

# 3.7

➜  cpython git:(pr_1982) python3.7 /tmp/foo.py
raises AttributeError for non-existent attribute

# With PR

➜  cpython git:(pr_1982) ./python.exe /tmp/foo.py
Traceback (most recent call last):
  File "/tmp/foo.py", line 7, in 
mock_foo(1, 2)
  File 
"/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/unittest/mock.py", 
line 1009, in __call__
_mock_self._mock_check_sig(*args, **kwargs)
  File 
"/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/unittest/mock.py", 
line 103, in checksig
sig.bind(*args, **kwargs)
  File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/inspect.py", 
line 3016, in bind
return args[0]._bind(args[1:], kwargs)
  File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/inspect.py", 
line 2937, in _bind
raise TypeError('too many positional arguments') from None
TypeError: too many positional arguments

--

___
Python tracker 

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



[issue36496] Local variables can be used uninitialized in _PyPreConfig_Read()

2019-03-31 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +vstinner

___
Python tracker 

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



[issue36496] Local variables can be used uninitialized in _PyPreConfig_Read()

2019-03-31 Thread Brad Larsen


Change by Brad Larsen :


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

___
Python tracker 

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



[issue36496] Local variables can be used uninitialized in _PyPreConfig_Read()

2019-03-31 Thread Brad Larsen


New submission from Brad Larsen :

In bpo-36301, in commit f72346c47537657a287a862305f65eb5d7594fbf, a couple 
possible uses of uninitialized variables were introduced into 
Python/preconfig.c.

In particular, in _PyPreConfig_Read(), along an error-handling path, the 
`init_utf8_mode` and `init_legacy_encoding` variables will be read 
uninitialized.

_PyInitError
_PyPreConfig_Read(_PyPreConfig *config, const _PyArgv *args)
{
/* ... */

if (args) {
err = _PyPreCmdline_SetArgv(, args);
if (_Py_INIT_FAILED(err)) {
goto done;/* ERROR 
HANDLING DONE HERE */
}
}

int init_utf8_mode = Py_UTF8Mode; /* 
VARIABLE INITIZLIED HERE */
#ifdef MS_WINDOWS
int init_legacy_encoding = Py_LegacyWindowsFSEncodingFlag;/* 
VARIABLE INITIZLIED HERE */
#endif

/* ... */

done:
if (init_ctype_locale != NULL) {
setlocale(LC_CTYPE, init_ctype_locale);
PyMem_RawFree(init_ctype_locale);
}
_PyPreConfig_Clear(_config);
Py_UTF8Mode = init_utf8_mode ;/* 
UNINITIALIZED READ HERE */
#ifdef MS_WINDOWS
Py_LegacyWindowsFSEncodingFlag = init_legacy_encoding;/* 
UNINITIALIZED READ HERE */
#endif
_PyPreCmdline_Clear();
return err;
}

--
components: Interpreter Core
messages: 339268
nosy: blarsen
priority: normal
severity: normal
status: open
title: Local variables can be used uninitialized in _PyPreConfig_Read()
versions: Python 3.8

___
Python tracker 

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



[issue36150] Possible assertion failures due to _ctypes.c's PyCData_reduce()

2019-03-31 Thread Zackery Spytz


Change by Zackery Spytz :


--
pull_requests: +12575

___
Python tracker 

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



[issue36442] Different ValueError for the same operation in List and Tuple

2019-03-31 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

> And seems that this issue is a duplicate of an old issue with a long 
> discussion and an unfinished patch, but currently I cannot find that issue.

possibly duplicate of issue13349 which was rejected ?

--
nosy: +xtreak

___
Python tracker 

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



[issue36466] Adding a way to strip annotations from compiled bytecode

2019-03-31 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

> So as long as we have a separate mechanism to disable this I'm not worried 

Having a separate mechanism is a good solution.

--

___
Python tracker 

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



[issue30587] Mock with spec object does not ensure method call signatures

2019-03-31 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +xtreak

___
Python tracker 

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



[issue30587] Mock with spec object does not ensure method call signatures

2019-03-31 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +cjw296, mariocj89, michael.foord
versions: +Python 3.8 -Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 
3.6, Python 3.7

___
Python tracker 

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



[issue36150] Possible assertion failures due to _ctypes.c's PyCData_reduce()

2019-03-31 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue36150] Possible assertion failures due to _ctypes.c's PyCData_reduce()

2019-03-31 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 5f2c50810a67982b0c80f6d3258fee3647f67005 by Serhiy Storchaka 
(Zackery Spytz) in branch 'master':
bpo-36150: Fix possible assertion failures due to _ctypes.c's PyCData_reduce(). 
(GH-12106)
https://github.com/python/cpython/commit/5f2c50810a67982b0c80f6d3258fee3647f67005


--

___
Python tracker 

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



[issue35947] Update libffi_msvc to current version of libffi

2019-03-31 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 48600c72c1afe1096c2412a135a43f8cdd895195 by Serhiy Storchaka 
(Zackery Spytz) in branch 'master':
bpo-35947: Fix a compiler warning in _ctypes.c's StructUnionType_paramfunc(). 
(GH-12629)
https://github.com/python/cpython/commit/48600c72c1afe1096c2412a135a43f8cdd895195


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue32531] gdb.execute can not put string value.

2019-03-31 Thread Berker Peksag


Change by Berker Peksag :


--
hgrepos:  -377

___
Python tracker 

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



[issue32531] gdb.execute can not put string value.

2019-03-31 Thread Berker Peksag


Berker Peksag  added the comment:

gdb.execute() is part of GDB's Python API and maintained by GDB maintainers. 
This tracker is for issues with Python interpreter and its standard library.

--
nosy: +berker.peksag
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



[issue36442] Different ValueError for the same operation in List and Tuple

2019-03-31 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Thus is definitely is not related to Argument Clinic.

And seems that this issue is a duplicate of an old issue with a long discussion 
and an unfinished patch, but currently I cannot find that issue.

--
components:  -Argument Clinic
type: behavior -> enhancement
versions: +Python 3.8 -Python 3.7

___
Python tracker 

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



[issue36466] Adding a way to strip annotations from compiled bytecode

2019-03-31 Thread Guido van Rossum


Guido van Rossum  added the comment:

There's a similar thing with docstrings though. Some code depend on docstrings 
(e.g. David Beazley's parser generator). help() of course also depends on it. 
And yet we have a way to disable it. (Same with asserts, plenty of code depends 
on them even though we recommend against it.)

So as long as we have a separate mechanism to disable this I'm not worried -- 
it's up to the person that runs the program to ensure that they don't use 
functionality that breaks when annotations are suppressed.

(Note that functools.singledispatch has an alternate registration syntax that 
doesn't require annotations.)

--

___
Python tracker 

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



From parsing a class to code object to class to mappingproxy to object (oh my!)

2019-03-31 Thread adam . preble
I have been mimicking basic Python object constructs successfully until I 
started trying to handle methods as well in my hand-written interpreter. At 
that point, I wasn't sure where to stage all the methods before they get 
shuffled over to an actual instance of an object. I'm having to slap this out 
here partially to rubber duck it and partially because I really don't know 
what's going on.

Here's something tangible we can use:
>>> def construct():
...   class Meow:
... def __init__(self):
...   self.a = 1
... def change_a(self, new_a):
...   self.a = new_a
...   return Meow()
...
>>> dis(construct)
  2   0 LOAD_BUILD_CLASS
  2 LOAD_CONST   1 (", line 2>)
  4 LOAD_CONST   2 ('Meow')
  6 MAKE_FUNCTION0
  8 LOAD_CONST   2 ('Meow')
 10 CALL_FUNCTION2
 12 STORE_FAST   0 (Meow)

  7  14 LOAD_FAST0 (Meow)
 16 CALL_FUNCTION0
 18 RETURN_VALUE

I've wrapped my class in a function so I could more readily poke it with a 
stick. I understand LOAD_BUILD_CLASS will invoke builtins.__build_class__(). By 
the way, why the special opcode for that? Anyways, it takes that code object, 
which looks to be particularly special.

Note that I'm inserting some newlines and extra junk for sanity:

>>> import ctypes
>>> c = ctypes.cast(0x021BD59170C0, ctypes.py_object).value
>>> c.co_consts
('construct..Meow',
", line 3>,
'construct..Meow.__init__',
", line 5>,
'construct..Meow.change_a',
None)

>>> c.co_names
('__name__', '__module__', '__qualname__', '__init__', 'change_a')

>>> dis(c.co_code)
  0 LOAD_NAME0 (0) -> __name__ ...
  2 STORE_NAME   1 (1) -> ... goes into __module__
  4 LOAD_CONST   0 (0) -> Name of the class = 
'construct..Meow' ...
  6 STORE_NAME   2 (2) -> ... goes into __qualname__
  8 LOAD_CONST   1 (1) -> __init__ code object
 10 LOAD_CONST   2 (2) -> The name "__init__" ...
 12 MAKE_FUNCTION0 -> ... Made into a function
 14 STORE_NAME   3 (3) -> Stash it
 16 LOAD_CONST   3 (3) -> The name "change_a" ...
 18 LOAD_CONST   4 (4) -> The __change_a__ code object ...
 20 MAKE_FUNCTION0 -> ... Made into a function
 22 STORE_NAME   4 (4) -> Stash it
 24 LOAD_CONST   5 (5) -> Returns None
 26 RETURN_VALUE

I'm not too surprised to see stuff like this since this kind of thing is what I 
expect to find in flexible languages that do object-oriented programming by 
basically blessing a variable and heaping stuff on it. It's just that I'm 
trying to figure out where this goes in the process of language parsing to 
class declaration to object construction.

What I'm assuming is that when builtins.__build_class__() is invoked, it does 
all the metaclass/subclass chasing first, and then ultimately invokes this code 
object to populate the class. If I look at the __dict__ for the class 
afterwards, I see:

mappingproxy(
{'__module__': '__main__',
'__init__': .Meow.__init__ at 0x021BD592AAE8>,
'change_a': .Meow.change_a at 0x021BD5915F28>,
'__dict__': ,
'__weakref__': ,
'__doc__': None})

What is the plumbing taking the result of that code object over to this proxy? 
I'm assuming __build_class__ runs that code object and then starts looking for 
new names and see to create this. Is this mapping proxy the important thing for 
carrying the method declaration?

Is this also where prepare (and __prepare__) comes into play? Running into that 
was where I felt the need to start asking questions because I got six layers 
deep and my brain melted.

I'm then assuming that in object construction, this proxy is carried by some 
reference to the final object in such a way that if the class's fields are 
modified, all instances would see the modification unless the local object 
itself was overridden.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue36494] bdb.Bdb.set_trace: should set f_trace_lines = True

2019-03-31 Thread daniel hahler


Change by daniel hahler :


--
components: +Library (Lib)
title: bdb: should set f_trace_lines = True -> bdb.Bdb.set_trace: should set 
f_trace_lines = True
type:  -> behavior

___
Python tracker 

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



[issue35272] sqlite3 get the connected database url

2019-03-31 Thread Berker Peksag


Change by Berker Peksag :


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



[issue36495] Out-of-bounds array reads in Python/ast.c

2019-03-31 Thread SilentGhost


Change by SilentGhost :


--
nosy: +gvanrossum
versions:  -Python 3.9

___
Python tracker 

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



[issue36495] Out-of-bounds array reads in Python/ast.c

2019-03-31 Thread Roundup Robot


Change by Roundup Robot :


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

___
Python tracker 

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



[issue36495] Out-of-bounds array reads in Python/ast.c

2019-03-31 Thread Brad Larsen


New submission from Brad Larsen :

There are currently 2 places in Python/ast.c on master where an out-of-bounds
array read can occur.

Both were introduced with the merge of of typed_ast into CPython in commit
dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c (bpo-35766, GH-11645).

In both places, the out-of-bounds array read occurs when an index variable is
incremented, then used before checking that it is still valid.

The first out-of-bounds read, in `handle_keywordonly_args()`, around line 1403:

case vfpdef:
case tfpdef:
if (i + 1 < NCH(n) && TYPE(CHILD(n, i + 1)) == EQUAL) {
expression = ast_for_expr(c, CHILD(n, i + 2));
if (!expression)
goto error;
asdl_seq_SET(kwdefaults, j, expression);
i += 2; /* '=' and test */
}
else { /* setting NULL if no default value exists */
asdl_seq_SET(kwdefaults, j, NULL);
}
if (NCH(ch) == 3) {
/* ch is NAME ':' test */
annotation = ast_for_expr(c, CHILD(ch, 2));
if (!annotation)
goto error;
}
else {
annotation = NULL;
}
ch = CHILD(ch, 0);
argname = NEW_IDENTIFIER(ch);
if (!argname)
goto error;
if (forbidden_name(c, argname, ch, 0))
goto error;
arg = arg(argname, annotation, NULL, LINENO(ch), ch->n_col_offset,
  ch->n_end_lineno, ch->n_end_col_offset,
  c->c_arena);
if (!arg)
goto error;
asdl_seq_SET(kwonlyargs, j++, arg);
i += 1; /* the name */
if (TYPE(CHILD(n, i)) == COMMA)   /* HERE, OOB read */
i += 1; /* the comma, if present */
break;

The second out-of-bounds read, in `ast_for_arguments()`, around line 1602:

/* ... */
case DOUBLESTAR:
ch = CHILD(n, i+1);  /* tfpdef */
assert(TYPE(ch) == tfpdef || TYPE(ch) == vfpdef);
kwarg = ast_for_arg(c, ch);
if (!kwarg)
return NULL;
i += 2; /* the double star and the name */
if (TYPE(CHILD(n, i)) == COMMA)   /* HERE, OOB read */
i += 1; /* the comma, if present */
break;
/* ... */

You might see these out-of-bounds reads as crashes at various points during the
build process if you configure as so:

$ clang --version
clang version 8.0.0 (tags/RELEASE_800/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin

$ clang++ --version
clang version 8.0.0 (tags/RELEASE_800/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin

$ export ASAN_OPTIONS=detect_leaks=0 CC=clang CXX=clang++
$ ./configure --with-address-sanitizer --without-pydebug

$ make   # might fail partway through, but a python binary should still be 
produced

Finally, to see crashes from the out-of-bounds reads:

$ ./python.exe -c 'def foo(f, *args, kw=None): pass'
=
==59698==ERROR: AddressSanitizer: heap-buffer-overflow on address 
0x61306740 at pc 0x009aff20 bp 0x7ffe94660260 sp 0x7ffe94660258
READ of size 2 at 0x61306740 thread T0
#0 0x9aff1f in handle_keywordonly_args /cpython/Python/ast.c:1403:21
#1 0x9af034 in ast_for_arguments /cpython/Python/ast.c:1588:31
#2 0x9bb174 in ast_for_funcdef_impl /cpython/Python/ast.c:1748:12
#3 0x99ce99 in PyAST_FromNodeObject /cpython/Python/ast.c:806:25
#4 0x7bc4a2 in PyParser_ASTFromStringObject 
/cpython/Python/pythonrun.c:1216:15
#5 0x7ba4cf in PyRun_StringFlags /cpython/Python/pythonrun.c:963:11
#6 0x7ba422 in PyRun_SimpleStringFlags /cpython/Python/pythonrun.c:461:9
#7 0x512c5e in pymain_run_command /cpython/Modules/main.c:220:11
#8 0x512c5e in pymain_run_python /cpython/Modules/main.c:501
#9 0x512c5e in _Py_RunMain /cpython/Modules/main.c:583
#10 0x5144e2 in pymain_main /cpython/Modules/main.c:612:12
#11 0x51485f in _Py_UnixMain /cpython/Modules/main.c:636:12
#12 0x7f62e8f92b96 in __libc_start_main 
/build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310
#13 0x437729 in _start (/cpython/python.exe+0x437729)

0x61306740 is located 0 bytes to the right of 384-byte region 
[0x613065c0,0x61306740)
allocated by thread T0 here:
#0 0x4e34ef in realloc 
/tmp/tmp.XYTE7P6bCb/final/llvm.src/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:165:3
#1 0x8fa635 in PyNode_AddChild /cpython/Parser/node.c:120:22
#2 0x9d16f6 in shift /cpython/Parser/parser.c:114:11
#3 0x9d16f6 in PyParser_AddToken /cpython/Parser/parser.c:285
#4 0x8fbee3 in parsetok /cpython/Parser/parsetok.c:332:14
#5 0x7bc44a in PyParser_ASTFromStringObject 
/cpython/Python/pythonrun.c:1206:15
#6 0x7ba4cf in 

[issue28559] Unclear error message when raising wrong type of exceptions

2019-03-31 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
status: open -> pending

___
Python tracker 

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



[issue36494] bdb: should set f_trace_lines = True

2019-03-31 Thread daniel hahler


Change by daniel hahler :


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

___
Python tracker 

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



[issue36494] bdb: should set f_trace_lines = True

2019-03-31 Thread daniel hahler


New submission from daniel hahler :

bdb.Bdb.set_trace should set "f_trace_lines = True" on frames explicitly.

Otherwise they might be skipped if something else has set it to False already, 
e.g. via a suggested change for coverage.py to set this for performance reasons 
(https://github.com/nedbat/coveragepy/pull/791).

--
messages: 339259
nosy: blueyed
priority: normal
severity: normal
status: open
title: bdb: should set f_trace_lines = True
versions: Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue36440] more helpful diagnostics for parser module

2019-03-31 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
versions: +Python 3.8 -Python 3.9

___
Python tracker 

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



[issue36253] Use after free in ctypes test suite

2019-03-31 Thread Brad Larsen


Brad Larsen  added the comment:

I was just going to submit a patch for this, then I found this issue.

I can confirm; I see the same use-after-free without the fix.

--
nosy: +blarsen

___
Python tracker 

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



[issue36493] Add math.midpoint(a,b) function

2019-03-31 Thread Stefan Behnel

New submission from Stefan Behnel :

I recently read a paper¹ about the difficulty of calculating the most exact 
midpoint between two floating point values, facing overflow, underflow and 
rounding errors. The intention is to assure that the midpoint(a,b) is

- actually within the interval [a,b]
- the floating point number in that interval that is closest to the real 
midpoint (i.e. (a+b)/2).

It feels like a function that should be part of Python's math module.

¹ 
https://hal.archives-ouvertes.fr/file/index/docid/576641/filename/computing-midpoint.pdf

The author proposes the following implementation (pages 20/21):

midpoint(a,b) = 
a  if a == b else # covers midpoint(inf, inf)
0  if a == -b else# covers midpoint(-inf, +inf)
-realmax  if a == -inf else   # min. double value
+realmax  if b == +inf else   # max. double value
round_to_nearest_even((a - a/2) + b/2)

I guess nans should simply pass through as in other functions, i.e. 
midpoint(a,nan) == midpoint(nan,b) == nan.

The behaviour for [a,inf] is decidedly up for discussion. There are certainly 
cases where midpoint(a,+inf) would best return +inf, but +realmax as an actual 
finite value also seems reasonable. OTOH, it's easy for users to promote 
inf->realmax or realmax->inf or even inf->a themselves, just like it's easy to 
check for +/-inf before calling the function. It just takes a bit longer to do 
these checks on user side. There could also be a "mode" argument that makes it 
return one of: a or b (i.e. the finite bound), +/-realmax or +/-inf in the two 
half-infinity cases.

What do you think about this addition?

--
components: Library (Lib)
messages: 339257
nosy: mark.dickinson, rhettinger, scoder, stutzbach
priority: normal
severity: normal
status: open
title: Add math.midpoint(a,b) function
type: enhancement
versions: Python 3.8

___
Python tracker 

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



[issue28718] '*' matches entire path in fnmatch

2019-03-31 Thread Toon Verstraelen


Toon Verstraelen  added the comment:

Just for reference, here are a few more implementations of the same idea, next 
to pywildcard, sometimes combined with other useful features:

- https://github.com/LawfulHacker/fnmatch2
- https://github.com/demurgos/py-pathmatch
- https://github.com/vidartf/globmatch
- https://github.com/facelessuser/wcmatch

The last one is rather active, with regular releases, last one on March 24, 
2019.

--

___
Python tracker 

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



[issue36485] Add a way to clear all caches

2019-03-31 Thread Ma Lin


Ma Lin  added the comment:

> My initial idea was to add a lightweight module cachesreg with two functions: 
> register() and clear_caches().

If it only has two functions, it could be a sub-module sys.cachesreg

Or a lifecycle module, as the name, dedicated to such kind of functions. 
Register callback functions for memory low, poweroff system, etc.
I don't want lifecycle module, just provide a possibility.

--

___
Python tracker 

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



[issue36485] Add a way to clear all caches

2019-03-31 Thread Anders Hovmöller

Anders Hovmöller  added the comment:

I think this is a great idea. We would have needed this many times for tests 
over the years.

--
nosy: +Anders.Hovmöller

___
Python tracker 

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



[issue18233] SSLSocket.getpeercertchain()

2019-03-31 Thread Hiroaki Kawai


Change by Hiroaki Kawai :


--
nosy: +Hiroaki.Kawai

___
Python tracker 

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



[issue36473] dictkeysobject: Add maximum iteration check for .values() and .items()

2019-03-31 Thread Thomas Perl


Thomas Perl  added the comment:

Repurposing this as per:

https://github.com/python/cpython/pull/12619#issuecomment-478076996

--
title: Detect all dictionary changes during iteration -> dictkeysobject: Add 
maximum iteration check for .values() and .items()

___
Python tracker 

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



[issue34160] ElementTree not preserving attribute order

2019-03-31 Thread Stefan Behnel

Stefan Behnel  added the comment:

Thanks to the discussion that rhettinger triggered on python-dev, it seems that 
there is a majority accordance for considering the previous ordering "undefined 
but deterministic" rather than "sorted", and for making the change from 
"arbitrarily sorted" to "user defined" in Py3.8. That matches the current 
status after the merge of the four pull requests, for both ElementTree and 
MiniDOM.

There also seems to be a large fraction of participants that would like to see 
a stdlib way to safely/correctly/easily compare XML output. IMHO, that is 
covered by issue13611, adding a C14N module to ElementTree. There is also a 
(Py2) C14N implementation for minidom, from the now unmaintained PyXML 
package¹, which, according to the license, is already distributed under Python 
copyright. I will try to bring at least the ET module in shape for integration 
before 3.8 beta1.

During the discussions, several ways were shown to achieve deterministic 
behaviour, also across Python releases. My proposal is therefore to *not* add a 
new "sort_attrs" option to the API, with the reasoning that it is a) not 
required for any of the use cases, b) not maintaining compatibility without 
code changes (neither backwards nor forward), and c) not what most people 
actually want who strive for deterministic output. Instead, I think we should 
concentrate on providing and documenting better ways to compare XML output.

¹ 
https://github.com/actmd/PyXML/blob/97f144152878a67cd95dd229fe72e86f19bce706/xml/dom/ext/c14n.py

--

___
Python tracker 

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



[issue36485] Add a way to clear all caches

2019-03-31 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +12571

___
Python tracker 

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



[issue36485] Add a way to clear all caches

2019-03-31 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

My initial idea was to add a lightweight module cachesreg with two functions: 
register() and clear_caches(). PR 12639 implements it.

But I like Brett's idea more, because it is simpler. The only disadvantage of 
it is that if you make a typo in __clearcache__, this function will be silently 
ignored.

I thought also about different levels of cachesreg.cachesreg.register() could 
take two arguments -- the level and the clearing function. Then 
cachesreg.clear_caches() could allow to clear only caches of specified level 
and smaller/larger.

Both PRs add clearing callbacks only for modules which already cleared in 
regrtests. There are more caches, and with implementing any of these ideas it 
will be easier to add clearing caches in other modules.

--

___
Python tracker 

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



[issue27181] Add geometric mean to `statistics` module

2019-03-31 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
keywords: +patch
pull_requests: +12570

___
Python tracker 

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



[issue36485] Add a way to clear all caches

2019-03-31 Thread Ma Lin


Ma Lin  added the comment:

I suggest the documentation be written in more detail.

For example, in __clearcache__'s section, state explicitly that this magic 
function is for module-level cache, and it will be invoked by 
sys.clear_caches().

Maybe also introduce the background: some caches may grow unlimitedly, 
sys.clear_caches() gives the user a chance to empty them.

--
nosy: +Ma Lin

___
Python tracker 

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



[issue36492] Deprecate passing some conflicting arguments by keyword

2019-03-31 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue36492] Deprecate passing some conflicting arguments by keyword

2019-03-31 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +xtreak

___
Python tracker 

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



[issue36492] Deprecate passing some conflicting arguments by keyword

2019-03-31 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

As Steve mentioned in the discussion about PEP 570 [1], some changes of 
parameters to positional-only are breaking (although there is no breaks in the 
stdlib code). Before making parameters positional-only we should add a 
deprecation warning for passing them as keyword arguments. Similarly to the 
code used in the UserDict constructor (see issue22609).

The following PR adds deprecation warnings for other parameters which should be 
positional-only. It also fixes bugs about nonavailability to pass special 
keyword names like "self" or "func". Just one example:

>>> import functools
>>> def f(self, func): pass
... 
>>> functools.partialmethod(f, func=chr)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: __init__() got multiple values for argument 'func'


[1] 
https://discuss.python.org/t/pep-570-python-positional-only-parameters/1078/53

--
components: Library (Lib)
messages: 339249
nosy: serhiy.storchaka
priority: normal
severity: normal
status: open
title: Deprecate passing some conflicting arguments by keyword
type: behavior
versions: Python 3.8

___
Python tracker 

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



[issue36491] sum function's start optional parameter documented in help but not implemented

2019-03-31 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
superseder:  -> Make *start* usable as a keyword argument for sum().

___
Python tracker 

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



[issue36491] sum function's start optional parameter documented in help but not implemented

2019-03-31 Thread Raymond Hettinger


Change by Raymond Hettinger :


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



[issue36491] sum function's start optional parameter documented in help but not implemented

2019-03-31 Thread Stefan Behnel


Stefan Behnel  added the comment:

Yes, duplicate of issue34637.

--

___
Python tracker 

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



[issue36490] Modernize function signature format in Archiving section of shutil doc

2019-03-31 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +giampaolo.rodola, tarek

___
Python tracker 

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



[issue36491] sum function's start optional parameter documented in help but not implemented

2019-03-31 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Is this about sum not accepting start as keyword argument? It's fixed with 
issue34637. The help function in the report is that start could only be a 
positional argument with start appearing before '/' in "sum(iterable, start=0, 
/)" . This has been changed in 3.8 to below signature.

sum(iterable, /, start=0)
Return the sum of a 'start' value (default: 0) plus an iterable of numbers

When the iterable is empty, return the start value.
This function is intended specifically for use with numeric values and may
reject non-numeric types.

$ python3.7
Python 3.7.1rc2 (v3.7.1rc2:6c06ef7dc3, Oct 13 2018, 05:10:29)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> sum(range(10), start=10)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: sum() takes no keyword arguments

# 3.8

$ ./python.exe
Python 3.8.0a3+ (heads/master:7444daada1, Mar 30 2019, 20:27:47)
[Clang 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> sum(range(10), start=10)
55

--
nosy: +rhettinger, xtreak

___
Python tracker 

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



[issue36491] sum function's start optional parameter documented in help but not implemented

2019-03-31 Thread Stefan Behnel


Stefan Behnel  added the comment:

It's currently implemented as a positional argument, not a keyword argument. 
Thus the "/" at the end of the signature in the help text. That also suggests 
that it was a conscious decision, not an oversight. Personally, I'd also prefer 
it if it was available as a keyword argument.

--
nosy: +scoder

___
Python tracker 

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



[issue36491] sum function's start optional parameter documented in help but not implemented

2019-03-31 Thread Camion


New submission from Camion :

>>> help(sum)
Help on built-in function sum in module builtins:

sum(iterable, start=0, /)
Return the sum of a 'start' value (default: 0) plus an iterable of numbers

When the iterable is empty, return the start value.
This function is intended specifically for use with numeric values and may
reject non-numeric types.

>>> sum([1, 2, 3], start=3)
Traceback (most recent call last):
  File "", line 1, in 
sum([1, 2, 3], start=3)
TypeError: sum() takes no keyword arguments

By the way, it is very annoying that the start value is not available, because 
it hampers the possibility to use sum with things like vectors.

--
components: Interpreter Core
messages: 339245
nosy: Camion
priority: normal
severity: normal
status: open
title: sum function's start optional parameter documented in help but not 
implemented
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