[issue29839] Avoid raising OverflowError in len() when __len__() returns negative large value

2017-04-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

> The doc does not specify that 'length' cannot be non-negative.

It does. https://docs.python.org/3/reference/datamodel.html#object.__len__

.. method:: object.__len__(self)

   Called to implement the built-in function :func:`len`.  Should return the 
length
   of the object, an integer ``>=`` 0.

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



[issue28765] _sre.compile(): be more strict on types of indexgroup and groupindex

2017-04-16 Thread Serhiy Storchaka

Changes 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



[issue29838] Check that sq_length and mq_length return non-negative result

2017-04-16 Thread Serhiy Storchaka

Changes 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



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

2017-04-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:


New changeset 89f9eb5b192b875c017d37cac16bd514aad9a801 by Serhiy Storchaka in 
branch '2.7':
bpo-29943: Remove the PySlice_GetIndicesEx() macro. (#1050)
https://github.com/python/cpython/commit/89f9eb5b192b875c017d37cac16bd514aad9a801


--

___
Python tracker 

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



[issue10076] Regex objects became uncopyable in 2.5

2017-04-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:


New changeset fdbd01151dbd5feea3e4c0316d102db3d2a2a412 by Serhiy Storchaka in 
branch 'master':
bpo-10076: Compiled regular expression and match objects now are copyable. 
(#1000)
https://github.com/python/cpython/commit/fdbd01151dbd5feea3e4c0316d102db3d2a2a412


--

___
Python tracker 

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



[issue10076] Regex objects became uncopyable in 2.5

2017-04-16 Thread Serhiy Storchaka

Changes 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



[issue30022] Get rid of using EnvironmentError and IOError

2017-04-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:


New changeset 55fe1ae9708d81b902b6fe8f6590e2a24b1bd4b0 by Serhiy Storchaka in 
branch 'master':
bpo-30022: Get rid of using EnvironmentError and IOError (except test… (#1051)
https://github.com/python/cpython/commit/55fe1ae9708d81b902b6fe8f6590e2a24b1bd4b0


--

___
Python tracker 

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



[issue30022] Get rid of using EnvironmentError and IOError

2017-04-16 Thread Serhiy Storchaka

Changes 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



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

2017-04-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:


New changeset 49a905958ffc2fcd5d1d1a293ae453d45deeb884 by Serhiy Storchaka in 
branch '3.5':
[3.5] bpo-29943: Do not replace the function PySlice_GetIndicesEx() with a 
macro (#1049)
https://github.com/python/cpython/commit/49a905958ffc2fcd5d1d1a293ae453d45deeb884


--

___
Python tracker 

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



[issue30017] zlib.error: Error -2 while flushing: inconsistent stream state

2017-04-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:


New changeset 8e5b52a8da07e781bda50ba0a7065b1058495a37 by Serhiy Storchaka in 
branch '3.6':
bpo-30017: Allowed calling the close() method of the zip entry writer object 
(#1041) (#1092)
https://github.com/python/cpython/commit/8e5b52a8da07e781bda50ba0a7065b1058495a37


--

___
Python tracker 

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



[issue30017] zlib.error: Error -2 while flushing: inconsistent stream state

2017-04-16 Thread Serhiy Storchaka

Changes 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



[issue30065] Insufficient validation in _posixsubprocess.fork_exec()

2017-04-16 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
assignee:  -> serhiy.storchaka

___
Python tracker 

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



[issue30070] Fix errors handling in the parser module

2017-04-16 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
assignee:  -> serhiy.storchaka

___
Python tracker 

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



[issue30080] Add the --duplicate option for timeit

2017-04-16 Thread Armin Rigo

Changes by Armin Rigo :


--
nosy:  -arigo

___
Python tracker 

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



[issue29902] copy breaks staticmethod

2017-04-16 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

I'd be very hesitant to add anything to 2.7 that changes (even broken) behavior 
here.  It might make more sense to backport the more strict checks to 3.5.  
OTOH, we can save people from all programming errors, and if warnings are 
basically ignored (plus, adding warnings *can* break things), then perhaps we 
should only document the limitations.

There's already some description of copy()'s limitations, so either add another 
warning there, or in the static method objects description in section 3.2

--

___
Python tracker 

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



[issue22319] mailbox.MH chokes on directories without .mh_sequences

2017-04-16 Thread R. David Murray

R. David Murray added the comment:

Honestly, given the open questions my inclination would be to reject this.

--

___
Python tracker 

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



[issue30081] Inconsistent handling of failure of PyModule_AddObject

2017-04-16 Thread Xiang Zhang

New submission from Xiang Zhang:

The doc of PyModule_AddObject()[1] states it steals a reference to *value*. But 
this is only the case when it succeed. On failure the reference is not stolen.

The usages of it across the code base are inconsistent. Some realizes this 
situation and depends on it: [2]. Some doesn't realize: [3]. Most just assume 
it always succeeds: [4].

BTW, it seems many modules doesn't release memories well in failure situations 
in their PyMOD_INIT. Maybe I miss some post-handling procedures?

[1] https://docs.python.org/3/c-api/module.html#c.PyModule_AddObject
[2] https://github.com/python/cpython/blob/master/Python/modsupport.c#L644
[3] https://github.com/python/cpython/blob/master/Modules/gcmodule.c#L1590
[4] 
https://github.com/python/cpython/blob/master/Modules/_datetimemodule.c#L5799

--
messages: 291750
nosy: xiang.zhang
priority: normal
severity: normal
status: open
title: Inconsistent handling of failure of PyModule_AddObject
type: behavior

___
Python tracker 

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



[issue30081] Inconsistent handling of failure of PyModule_AddObject

2017-04-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

This is a duplicate of issue26868 and issue26871. There is also a thread on 
Python-Dev.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue29902] copy breaks staticmethod

2017-04-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

If add just warnings we are free to add any warnings in 2.7 in Py3k compatible 
mode (option -3).

--

___
Python tracker 

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



[issue30081] Inconsistent handling of failure of PyModule_AddObject

2017-04-16 Thread Xiang Zhang

Xiang Zhang added the comment:

Ohh, I am not alone. :-)

--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Change weird behavior of PyModule_AddObject()

___
Python tracker 

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



[issue22319] mailbox.MH chokes on directories without .mh_sequences

2017-04-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Do you mean rejecting the support of Claws Mail IMAP-cache folder or just the 
patch?

--

___
Python tracker 

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



[issue30079] Explain why it is recommended to pass args as a string rather than as a sequence If shell is True

2017-04-16 Thread R. David Murray

R. David Murray added the comment:

Note the subtlety here on unix:

rdmurray@pydev:~/python/p36[3.6]>cat temp.sh
#!/bin/bash
echo $0
echo $1

>>> subprocess.call(['./temp.sh', 'spam', 'eggs'], shell=True)
./temp.sh


0
>>> subprocess.call(['./temp.sh $0 $1', 'spam', 'eggs'], shell=True)
./temp.sh
spam
eggs
0

--

___
Python tracker 

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



[issue30079] Explain why it is recommended to pass args as a string rather than as a sequence If shell is True

2017-04-16 Thread R. David Murray

R. David Murray added the comment:

Woops, cut and paste error, there should have been an "echo $2" line in that 
script as well.

--

___
Python tracker 

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



[issue22319] mailbox.MH chokes on directories without .mh_sequences

2017-04-16 Thread R. David Murray

R. David Murray added the comment:

The support.  ClawsMail is broken, IMO.

--

___
Python tracker 

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



[issue19184] dis module has incorrect docs for RAISE_VARARGS

2017-04-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

May be just provide Python statements that correspond different numbers of 
parameters? 0 -- ``raise``, 1 -- ``raise TOS``, 2 -- ``raise TOS1 from TOS``.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue22319] mailbox.MH chokes on directories without .mh_sequences

2017-04-16 Thread R. David Murray

R. David Murray added the comment:

If there is a way to resolve the lock issue we can consider it.  But (without 
looking at the code again) I suspect the locking is too deeply embedded in the 
mbox logic for this to be a safe change.

--

___
Python tracker 

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



[issue30077] Support Apple AIFF-C pseudo compression in aifc.py

2017-04-16 Thread Xiang Zhang

Changes by Xiang Zhang :


--
components: +Library (Lib) -Extension Modules
versions: +Python 3.7 -Python 3.6

___
Python tracker 

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



[issue30077] Support Apple AIFF-C pseudo compression in aifc.py

2017-04-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Seems the "sowt" compression is not just a no-op operation. Perhaps it should 
change a byte order.

Needed tests and test files for the new compression.

--
assignee:  -> serhiy.storchaka
nosy: +serhiy.storchaka
stage:  -> patch review

___
Python tracker 

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



[issue30082] hide command prompt when using subprocess.Popen with shell=False on Windows

2017-04-16 Thread Philip Lee

New submission from Philip Lee:

First, It is nearly useless for the command prompt to pop up during  the 
running time of subprocess.Popen with shell=False.
Second, the popping up command prompt would interrupt users and do bad to user 
experience of GUI applications.
Third, I found QProcess within Qt won't pop up the command prompt  in using.

It would be convenient to add an argument to suppress the command prompt from 
popping up when using subprocess.Popen with shell=False on Windows, many users 
are missing the feature and these are many similar feature request questions 
like the following 
http://stackoverflow.com/questions/7006238/how-do-i-hide-the-console-when-i-use-os-system-or-subprocess-call
http://stackoverflow.com/questions/1765078/how-to-avoid-console-window-with-pyw-file-containing-os-system-call/12964900#12964900
http://stackoverflow.com/questions/1016384/cross-platform-subprocess-with-hidden-window

--
components: Library (Lib)
messages: 291760
nosy: iMath
priority: normal
severity: normal
status: open
title: hide command prompt when using subprocess.Popen with shell=False on 
Windows
type: enhancement

___
Python tracker 

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



[issue30077] Support Apple AIFF-C pseudo compression in aifc.py

2017-04-16 Thread Xiang Zhang

Xiang Zhang added the comment:

Anyway, such a function addition could only get into 3.7.

--
nosy: +xiang.zhang

___
Python tracker 

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



[issue30083] Asyncio: GeneratorExit + strange exception

2017-04-16 Thread Марк Коренберг

New submission from Марк Коренберг:

How to reproduce: Run the following program:
=
import asyncio
async def handle_connection(reader, writer):
try:
await reader.readexactly(42)
except BaseException as err:
print('Interesting: %r.' % err)
raise
finally:
writer.close()

loop = asyncio.get_event_loop()
coro = asyncio.start_server(handle_connection, '127.0.0.1', )
server = loop.run_until_complete(coro)
try:
loop.run_forever()
except KeyboardInterrupt:
print('KeyboardInterrupt catched.')
server.close()
loop.run_until_complete(server.wait_closed())
loop.close()
=

0. Python 3.5.2
1. Connect using telnet to localhost and port 888, type one short line and 
press Enter.
2. Type Ctrl+C in terminal where programw is running.
3. You will see the following output:

=
^CKeyboardInterrupt catched.
Interesting: GeneratorExit().
Exception ignored in: 
Traceback (most recent call last):
  File "bug.py", line 12, in handle_connection
writer.close()
  File "/usr/lib/python3.5/asyncio/streams.py", line 306, in close
return self._transport.close()
  File "/usr/lib/python3.5/asyncio/selector_events.py", line 591, in close
self._loop.call_soon(self._call_connection_lost, None)
  File "/usr/lib/python3.5/asyncio/base_events.py", line 567, in call_soon
handle = self._call_soon(callback, args)
  File "/usr/lib/python3.5/asyncio/base_events.py", line 576, in _call_soon
self._check_closed()
  File "/usr/lib/python3.5/asyncio/base_events.py", line 356, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Task was destroyed but it is pending!
task:  
wait_for=>
=

This is almost canonical example of asyncio usage. So I have two questions:

1. Why coroutine is interrupted with GeneratorExit instead of CancelledError ?
2. Why something happend AFTER io loop is closed ?
3. How to code all that right ? I want to close connection on any error. 
Example provided is simplified code. In real code it looks like:

=
try:
await asyncio.wait_for(self._handle_connection(reader, writer), 60)
except asyncio.TimeoutError:
writer.transport.abort()
except asyncio.CancelledError:
writer.transport.abort()
except Exception:
writer.transport.abort()
finally:
writer.close()
=

--
messages: 291763
nosy: socketpair
priority: normal
severity: normal
status: open
title: Asyncio: GeneratorExit + strange exception

___
Python tracker 

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



[issue30083] Asyncio: GeneratorExit + strange exception

2017-04-16 Thread Марк Коренберг

Changes by Марк Коренберг :


--
components: +asyncio
nosy: +yselivanov
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



[issue14976] queue.Queue() is not reentrant, so signals and GC can cause deadlocks

2017-04-16 Thread Itamar Turner-Trauring

Itamar Turner-Trauring added the comment:

This bug was closed on the basis that signals + threads don't interact well. 
Which is a good point.

Unfortunately this bug can happen in cases that have nothing to do with 
signals. If you look at the title and some of the comments it also happens as a 
result of garbage collection: in `__del__` methods and weakref callbacks.

Specifically, garbage collection can happen on any bytecode boundary and cause 
reentrancy problems with Queue.

The attached file is an attempt to demonstrate this: it runs and runs until GC 
happens and then deadlocks for me (on Python 3.6). I.e. it prints GC! and after 
that no further output is printed and no CPU usage reported.

Please re-open this bug: if you don't want to fix signal case that's fine, but 
the GC case is still an issue.

--
versions: +Python 3.5, Python 3.6
Added file: http://bugs.python.org/file46806/queuebug2.py

___
Python tracker 

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



[issue11822] Improve disassembly to show embedded code objects

2017-04-16 Thread Raymond Hettinger

Raymond Hettinger added the comment:

> if we modify dis() instead of adding a new function, then
> the default behaviour needs to be non-recursive for 
> backwards compatibility reasons

I don't see how we have any backward compatibility issues.  The dis() function 
is purely informational like help().  

The problem is it doesn't show important information, list comprehensions are 
now effectively hidden from everyone who isn't clever and persistent.   

I use dis() as a teaching aid in my Python courses and as a debugging tool when 
doing consulting.  From my point of view, it is effectively broken in Python 3.

--

___
Python tracker 

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



[issue30077] Support Apple AIFF-C pseudo compression in aifc.py

2017-04-16 Thread Toby Thurston

Toby Thurston added the comment:

I think it's probably better as a no-op.  Currently in my patch I just put 

return data

You could do

return data[::-1]

to reverse the sample, so that it came out as big endian, but if you leave it 
as a no-op then the data is returned in the native format for Intel Mac OS, 
which is the whole point of the "sowt" encoding.  Either way, the user can 
easily reverse the data in a `unpack` format if they want to, but in my own 
testing it seemed easier and simpler just to leave it in the native format. 
Then basically "it just works".

The patch as I've proposed it works fine on my MacOS boxes, but I have only 
tested it with AIFF-C files from one source.

--

___
Python tracker 

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



[issue23787] sum() function docstring lists arguments incorrectly

2017-04-16 Thread Raymond Hettinger

Raymond Hettinger added the comment:

[Serhiy]
> Raymond, could you open a pull request?

Perhaps you could do it for me.  I still haven't had time to wrestle with the 
github switchover, so I'm effectively crippled for a while.

[Valentine]
> Seems like mentioning string was really a bad idea  that's
> why I considered the docstring [subtly] wrong.

Not really wrong in a way that confuses typical users.  That docstring has been 
successfully communicating the basic API for over a decade.

Over time, the docs have slowly converted the old "sequence" references to 
"iterable".  The docs were never really wrong; instead, we just got more 
precise by what we meant by sequence versus iterable (i.e. before the ABCs were 
introduced, the term "sequence" was used in a somewhat generic way to mean "a 
succession of data values"). 

Also note, it is an interesting paradox that docstrings that are the most 
helpful to most people most of the time are brief and little loose with 
terminology.  In general, they reward those who are doing quick lookups for API 
reminders, but do not reward pedantic close readings.

We'll go ahead and change "sequence" to "iterable" for sum(), but I think that 
is only a minor win.  The change makes it more technically correct but less 
friendly to some users (i.e. people need to be taught what "iterable" means 
while they tend to get the notion of "sequence of values" without any training).

As far as the exclusion of string goes, there were plenty of debate about 
whether to allow them or to more broadly disallow many data types where summing 
works quadratically.  The final decision was made by the BDFL and it seems to 
have been the right decision for just about everyone.  You can take issue with 
his decision, but that would be pointless.

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

___
Python tracker 

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



[issue26828] Implement __length_hint__() on map() and filter() to optimize list(map) and list(filter)

2017-04-16 Thread Raymond Hettinger

Raymond Hettinger added the comment:

[STINNER Victor]
> Oh, there is no slot for __length_hint__(). 
> Maybe we should also try to add a new slot for it?

+1

--

___
Python tracker 

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



[issue30084] about starred expression

2017-04-16 Thread umedoblock

New submission from umedoblock:

Hi, all.

First of all, my python environment is below.

Python 3.5.2+ (default, Sep 22 2016, 12:18:14) 
[GCC 6.2.0 20160927] on linux

= differ evaluation order about starred expression
I get below result then I run x.py
==
  File "/home/umedoblock/x.py", line 4
(*(1, 2))
^
SyntaxError: can't use starred expression here
==

Next, I comment out line 4 and run Python3.
I got below result.
And I feel strange behavior above result.
Because I think that Python should return same result above and below. 
==
Traceback (most recent call last):
  File "/home/umedoblock/x.py", line 1, in 
list(*(1, 2))
TypeError: list() takes at most 1 argument (2 given)
==

= pass or not about starred expression.
list expression pass starred expression, the other hand
tuple expression cannot pass starred expression.
I hope to pass starred expression about list and tuple.
>>> [*(1, 2)]
[1, 2]
>>> (*(1, 2))
  File "", line 1
SyntaxError: can't use starred expression here

--
components: Regular Expressions
files: x.py
messages: 291769
nosy: ezio.melotti, mrabarnett, umedoblock
priority: normal
severity: normal
status: open
title: about starred expression
type: behavior
versions: Python 3.5
Added file: http://bugs.python.org/file46807/x.py

___
Python tracker 

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



[issue23787] sum() function docstring lists arguments incorrectly

2017-04-16 Thread Mariatta Wijaya

Changes by Mariatta Wijaya :


--
assignee: docs@python -> Mariatta
nosy: +Mariatta
versions: +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



[issue30084] starred tuple expression vs list display and function call

2017-04-16 Thread Martin Panter

Martin Panter added the comment:

This doesn’t seem like a bug to me. At least it is consistent with the rule for 
making a tuple when there are commas versus returning the direct expression 
when there are no commas:

>>> x = (1); type(x)

>>> x = (1,); type(x)


I don’t think it is worth changing the syntax again just to pack a single 
starred expression into a tuple without a comma. If you really want to do that, 
it would be clearer to write

expression = (1, 2)
tuple_1 = (*expression,)  # Brackets and comma suggest a tuple
tuple_2 = tuple(expression)  # Tuple constructor even more obvious

Allowing tuple packing without a comma would add a new inconsistency with 
function calls. It would conflict with your list(*(1, 2)) case:

list(*(1, 2))  # Currently equivalent to list(1, 2)
list( (*(1, 2)) )  # Would be equivalent to list( (1, 2) )

The root problem IMO is that round brackets and commas have too many 
inconsistent special cases in Python (simple expressions vs tuples, tuples with 
zero, one or more items, function calls and signatures, generator expressions, 
unpacking assignments, etc). But it may be too hard to change any of this.

--
components: +Interpreter Core -Regular Expressions
nosy: +martin.panter
title: about starred expression -> starred tuple expression vs list display and 
function call

___
Python tracker 

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



[issue30080] Add the --duplicate option for timeit

2017-04-16 Thread Raymond Hettinger

Raymond Hettinger added the comment:

+1 I've long used this technique when timing fast statements.  See 
https://code.activestate.com/recipes/577834 for an example.

--

___
Python tracker 

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



[issue30084] starred tuple expression vs list display and function call

2017-04-16 Thread Steven D'Aprano

Steven D'Aprano added the comment:

> list expression pass starred expression, the other hand
> tuple expression cannot pass starred expression.

You are misinterpreting what you are seeing.

( ) is not a tuple expression (except for the special case of empty brackets, 
which makes an empty tuple). It's just grouping an expression. So (*x) is 
equivalent to just bare *x.

To make a tuple, you need a comma.

Apart from the empty tuple, the brackets are just for grouping. Put a comma 
after the starred expression and it will work:

py> t = 1, 2
py> t
(1, 2)
py> (*t,)
(1, 2)


The trailing comma is allowed in lists as well:

py> [*t,]
[1, 2]


I agree with Martin: there's no bug here, the behaviour is consistent with the 
way tuples and lists are normally created, and there's no need to make (*t) yet 
another special case.

If you really want to argue in favour of this change, I suggest you discuss it 
on the Python-Ideas mailing list and see if you can get community consensus for 
it. *If* you get agreement that this is a good idea, then you can re-open this.

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



[issue30051] Document that the random module doesn't support fork

2017-04-16 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee: docs@python -> rhettinger

___
Python tracker 

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



[issue30051] Document that the random module doesn't support fork

2017-04-16 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Several thoughts:

* AFAICT, in entire the history of this module, no user has ever reported this 
as being a source of confusion, so I don't think there is a real documentation 
issue here. 

* Regarding, "after fork, the parent and the child produce the same "random" 
number sequence", this is the expected behavior of a PRNG.  If it did something 
thing different, THAT would be a bug.

* There random module is likely the wrong place for a note.   It is more 
properly a topic about forking itself.  Perhaps there is room for a FAQ entry 
about forking elaborating on the broad range of state that is shared across 
forks (lock and file descriptors, etc).

* For those who need it, the API already supports reseeding and a way to make 
new instances of Random.  Both of those are the standard ways of doing it for 
people who need independent generators in different threads.

--

___
Python tracker 

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



[issue30085] Discourage operator.__dunder__ functions

2017-04-16 Thread Steven D'Aprano

New submission from Steven D'Aprano:

As discussed on the Python-Ideas mailing list, it is time to discourage the use 
of operator.__dunder__ functions. Not to remove them or deprecate them, just 
change the documentation to make it clear that the dunderless versions are 
preferred.

Guido +1'ed this suggestion, and there were no objections:

https://mail.python.org/pipermail/python-ideas/2017-April/045424.html

--
assignee: docs@python
components: Documentation
messages: 291774
nosy: docs@python, ncoghlan, steven.daprano, terry.reedy
priority: normal
severity: normal
status: open
title: Discourage operator.__dunder__ functions

___
Python tracker 

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



[issue30080] Add the --duplicate option for timeit

2017-04-16 Thread Guido van Rossum

Changes by Guido van Rossum :


--
nosy:  -Guido.van.Rossum, gvanrossum

___
Python tracker 

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



[issue23787] sum() function docstring lists arguments incorrectly

2017-04-16 Thread Raymond Hettinger

Raymond Hettinger added the comment:

I believe this is just a 2.7 issue.

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



[issue30040] new empty dict can be more small

2017-04-16 Thread Louie Lu

Louie Lu added the comment:

Inada's patch version act different inside `PyObject_SetItem`, 

when running this code: 'x = {}; x['a'] = 123'

at PyObject_SetItem,

patch version goes to this line:
  >│179 if (m && m->mp_ass_subscript)
   │180 return m->mp_ass_subscript(o, key, value);

but original version goes to:
  >│182 if (o->ob_type->tp_as_sequence) {
   │183 if (PyIndex_Check(key)) {

I think that's why the performance issue came out, still digging why this 
happened.

--
nosy: +louielu

___
Python tracker 

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



[issue30040] new empty dict can be more small

2017-04-16 Thread Louie Lu

Louie Lu added the comment:

forgive my words, I trace the wrong code, sorry about that.

--

___
Python tracker 

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



[issue30076] Opcode names BUILD_MAP_UNPACK_WITH_CALL and BUILD_TUPLE_UNPACK_WITH_CALL are too long

2017-04-16 Thread Nick Coghlan

Nick Coghlan added the comment:

If we used the names from inspect.Parameter.kind 
(https://docs.python.org/3/library/inspect.html#inspect.Parameter.kind) these 
would become:

* BUILD_VAR_POSITIONAL
* BUILD_VAR_KEYWORD

which would be 20 and 17 letters long, respectively.

I think that would also make the disassembled bytecode more self-explanatory:

>>> dis.dis('f(a, b, *args, x=x, y=y, **kw)')
  1   0 LOAD_NAME0 (f)
  2 LOAD_NAME1 (a)
  4 LOAD_NAME2 (b)
  6 BUILD_TUPLE  2
  8 LOAD_NAME3 (args)
 10 BUILD_VAR_POSITIONAL 2
 12 LOAD_NAME4 (x)
 14 LOAD_NAME5 (y)
 16 LOAD_CONST   0 (('x', 'y'))
 18 BUILD_CONST_KEY_MAP  2
 20 LOAD_NAME6 (kw)
 22 BUILD_VAR_KEYWORD2
 24 CALL_FUNCTION_EX 1
 26 RETURN_VALUE

--

___
Python tracker 

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



[issue30084] starred tuple expression vs list display and function call

2017-04-16 Thread umedoblock

umedoblock added the comment:

Sorry and thanks to Martin and Steven.
I agree with your post about first my post.
I understand "(*x) is equivalent to just bare *x."

--

___
Python tracker 

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




[issue11822] Improve disassembly to show embedded code objects

2017-04-16 Thread Nick Coghlan

Nick Coghlan added the comment:

Yeah, I was mixing this up with getargspec (et al), which get used by IDEs and 
similar tools. While third party tools do use the disassembler, they typically 
won't use its display logic directly unless they're just dumping the output to 
a terminal equivalent.

Given that, a "depth=None" parameter on `dis` and `disassemble` would provide 
the default behaviour of rendering the entire compilation tree, while still 
allowing turning off recursion entirely ("depth=0"), or limiting it to a 
desired number of levels ("depth=1", etc).

--

___
Python tracker 

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



[issue30086] type() and len() recognize "abc", expression as "abc" string.

2017-04-16 Thread umedoblock

New submission from umedoblock:

But I found a real bug to use a tuple with a comma.

Python3 recognized "abc", expression as tuple of one element.
But type() and len() recognize "abc", expression as "abc" string.
So now, I found a real bug.

I'll show you below sentences.

>>> "abc",
('abc',)
>>> obj = "abc",
>>> obj
('abc',)
>>> type(obj)

>>> len(("abc",))
1
>>> len(obj)
1

>>> type("abc",)

>>> len("abc",)
3

--
components: Regular Expressions
messages: 291781
nosy: ezio.melotti, mrabarnett, umedoblock
priority: normal
severity: normal
status: open
title: type() and len() recognize "abc", expression as "abc" string.
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



[issue30086] type() and len() recognize "abc", expression as "abc" string.

2017-04-16 Thread Raymond Hettinger

Raymond Hettinger added the comment:

What you're seeing is a feature of the grammar.

Function allow an optional trailing comma in the argument list:

>>> pow(2, 5)
32
>>> pow(2, 5,)
32

So, to create a tuple inside in an argument list, you need the extra layer of 
parentheses.

Sorry, this isn't a real bug.  It is just a conflict resolution between use of 
a comma to separate arguments in a function call and use of a comma to create a 
tuple.

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



[issue25794] __setattr__ does not always overload operators

2017-04-16 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee:  -> serhiy.storchaka

___
Python tracker 

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



[issue23174] shelve.open fails with error "anydbm.error: db type could not be determined"

2017-04-16 Thread Roundup Robot

Changes by Roundup Robot :


--
pull_requests: +1291

___
Python tracker 

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



[issue23174] shelve.open fails with error "anydbm.error: db type could not be determined"

2017-04-16 Thread Anand Reddy Pandikunta

Anand Reddy Pandikunta added the comment:

dbm.whichdb mentions that it returns empty string ('') if the file’s format 
can’t be guessed. Enhancing exception message should suffice.

--
nosy: +ChillarAnand

___
Python tracker 

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



[issue23174] shelve.open fails with error "anydbm.error: db type could not be determined"

2017-04-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Proposed error message isn't correct. The file extension is not the only method 
for determining db type.

Current error message looks good to me and I don't see how it can be enhanced.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue30087] pdb issue with type conversion

2017-04-16 Thread Christoph Zimmermann

New submission from Christoph Zimmermann:

Types cannot be converted properly while running under pdb control:

python
>>> t=(1,2,3)
>>> list(t)
[1, 2, 3]

python pdb.py
(Pdb) t=(1,2,3)
(Pdb) list(t)
*** Error in argument: '(t)'

--
components: Extension Modules
messages: 291786
nosy: Christoph Zimmermann
priority: normal
severity: normal
status: open
title: pdb issue with type conversion
versions: Python 2.7, Python 3.6

___
Python tracker 

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



[issue30087] pdb issue with type conversion

2017-04-16 Thread Cuong Manh Le

Cuong Manh Le added the comment:

list is a pdb command, not the builtin list when you called it in pdb

--
nosy: +Cuong Manh Le

___
Python tracker 

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