[issue33372] Wrong calculation

2018-04-26 Thread Tim Peters

Tim Peters  added the comment:

Please find a minimal example that illustrates the problem you think you've 
found, and paste the plain text _into_ the bug report.

In the meantime, I'm closing this as "not a bug".  The division operator 
applied to integers in Python 2 defaults doing truncating integer division, and 
in Python 3 defaults to doing floating point division instead.  So this example 
all by itself is enough to show a difference:

Under Python 2.7.11:

>>> 1/8
0

Under Python 3.6.5:

>>> 1/8
0.125

Both are expected.

In exactly the same way, the subexpression "2*1*10/100*10*10+100/10" in the 
code you pasted returns the integer 10 under Python 2 but the floating point 
value 30.0 under Python 3.

--
nosy: +tim.peters
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



[issue33372] Wrong calculation

2018-04-26 Thread an0n.r00t32

New submission from an0n.r00t32 :

I found that python calculate this wrong. Other calculators gave me 9997809307 
not 9997809507 (python), even python3 calculated it correctly. Here is the 
computation expression which Python 2.7 calculated wrong.

https://pastebin.com/uKx1FYx3

--
messages: 315826
nosy: an0n.r00t32
priority: normal
severity: normal
status: open
title: Wrong calculation
type: performance
versions: Python 2.7

___
Python tracker 

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



[issue33363] async for statement is not a syntax error in sync context

2018-04-26 Thread Zsolt Dollenstein

Change by Zsolt Dollenstein :


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

___
Python tracker 

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



[issue33369] Removing Popen log files in threads is racy on Windows

2018-04-26 Thread Zachary Ware

Zachary Ware  added the comment:

You will get no support for Python 2.7.3 out of us (that patch release is over 
6 years old!  At least try 2.7.14, or wait a week for 2.7.15) and most of us 
have lost interest in 2.7 altogether, particularly on Windows.  However, this 
sounds very much like other issues I've seen around the timing of Windows file 
handle handling.  Try adding a retry loop with a short sleep around your 
`os.remove` call.

--

___
Python tracker 

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



[issue33371] Clarify the predicate parameter of inspect.getmembers

2018-04-26 Thread Brian Curtin

Change by Brian Curtin :


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



[issue33371] Clarify the predicate parameter of inspect.getmembers

2018-04-26 Thread Brian Curtin

Change by Brian Curtin :


--
keywords: +patch
pull_requests: +6311
stage: needs patch -> patch review

___
Python tracker 

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



[issue33371] Clarify the predicate parameter of inspect.getmembers

2018-04-26 Thread Brian Curtin

New submission from Brian Curtin :

It would be helpful to clarify what the *predicate* callable will be called 
with. I had to look into the source in order to figure out what it was going to 
receive.

--
assignee: brian.curtin
components: Documentation
messages: 315824
nosy: brian.curtin
priority: normal
severity: normal
stage: needs patch
status: open
title: Clarify the predicate parameter of inspect.getmembers

___
Python tracker 

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



[issue33370] Addition of mypy cache to gitignore

2018-04-26 Thread Ekin Dursun

Change by Ekin Dursun :


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

___
Python tracker 

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



[issue33370] Addition of mypy cache to gitignore

2018-04-26 Thread Ekin Dursun

New submission from Ekin Dursun :

Since Python developers started to use mypy, I need we should add .mypy_cache 
directories to .gitignore.

--
messages: 315823
nosy: onlined
priority: normal
severity: normal
status: open
title: Addition of mypy cache to gitignore
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



[issue33369] Removing Popen log files in threads is racy on Windows

2018-04-26 Thread Peter Boström

New submission from Peter Boström :

OS: Windows 10, version 1607 (OS Build 14393.2189)
Python --version: Python 2.7.3

Removing logfiles files just after Popen().wait() outside an open() block is 
racy on Windows. This seems to require multiple parallel workers to pull off, 
not sure where the synchronization issue lies (interpreter or os).

This report is spun off from the following pull request where we ran into the 
issue (we always log to log files instead of memory pipes but sometimes discard 
them after the worker has finished): 
https://github.com/google/gtest-parallel/pull/59#issuecomment-369551914

Attaching repro script, in it essentially all workers do this:

  command = ['ping', '-n', '1', '127.0.0.1']
  with open(file_name, 'w') as file_obj:
task = subprocess.Popen(command, stdout=file_obj, stderr=file_obj)
task.wait()

  print 'Removing %s\n' % file_name
  os.remove(file_name)

Here os.remove() fails fairly often with an exception even though there should 
be no handles left to the file: WindowsError: [Error 32] The process cannot 
access the file because it is being used by another process: '25436.log'

Run (this seems to repro pretty reliably, more than half of the time on my 
machine):

C:\src>del *.log

C:\src>python racy_windows.py
Logging to 24788.log
Logging to 1052.log


Logging to 32320.log
Logging to 29316.log


Removing 1052.log

Exception in thread Thread-2:
Traceback (most recent call last):
  File "C:\python_27_amd64\files\lib\threading.py", line 551, in 
__bootstrap_inner
self.run()
  File "C:\python_27_amd64\files\lib\threading.py", line 504, in run
self.__target(*self.__args, **self.__kwargs)
  File "racy_windows.py", line 19, in __call__
os.remove(file_name)
WindowsError: [Error 32] The process cannot access the file because it is being 
used by another process: '1052.log'

Removing 24788.log

Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\python_27_amd64\files\lib\threading.py", line 551, in 
__bootstrap_inner
self.run()
  File "C:\python_27_amd64\files\lib\threading.py", line 504, in run
self.__target(*self.__args, **self.__kwargs)
  File "racy_windows.py", line 19, in __call__
os.remove(file_name)
WindowsError: [Error 32] The process cannot access the file because it is being 
used by another process: '24788.log'

Removing 29316.log
Removing 32320.log

--
components: Windows
files: racy_windows.py
messages: 315822
nosy: paul.moore, pbos, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Removing Popen log files in threads is racy on Windows
type: behavior
versions: Python 2.7
Added file: https://bugs.python.org/file47552/racy_windows.py

___
Python tracker 

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



[issue33000] IDLE Doc: Text consumes unlimited RAM, consoles likely not

2018-04-26 Thread Big Stone

Big Stone  added the comment:

done, sorry for the (now) missleading icon name.

--

___
Python tracker 

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



[issue33354] Python2: test_ssl fails on non-ASCII path

2018-04-26 Thread Pablo Galindo Salgado

Change by Pablo Galindo Salgado :


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

___
Python tracker 

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



[issue33358] [EASY] x86 Ubuntu Shared 3.x: test_embed.test_pre_initialization_sys_options() fails

2018-04-26 Thread Pablo Galindo Salgado

Change by Pablo Galindo Salgado :


--
keywords: +patch
pull_requests: +6308
stage: needs patch -> patch review

___
Python tracker 

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



[issue33326] Convert collections (cmp_op, hasconst, hasname and others) in opcode module to more optimal type

2018-04-26 Thread Kirill Balunov

Kirill Balunov  added the comment:

I apologize for FutureWarning and __getattr__. I myself do not understand what 
I meant and how it will help in this situation :)

--

___
Python tracker 

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



[issue33274] minidom removeAttributeNode returns None

2018-04-26 Thread R. David Murray

R. David Murray  added the comment:

The rule in Python is that when a function mutates its argument it does *not* 
return a pointer to the object it just mutated, and likewise a method does 
*not* return a pointer to the parent object.  Usually this means a mutating 
function/method return None, but there are a number of exceptions (dict.pop(), 
for example).

If I understand correctly, in this case the method is returning the object that 
is its argument, and *that* object is not changed.  So I'd say this is an edge 
case.  Given the existence of a standard, I think it would probably be 
reasonable to implement it that way.  You could think of it as analogous to 
list.pop(N), although in that case the argument is not what is returned, but 
rather the value.  I think it is still analogous, though, since the way you 
identify the node to pop in this case is by its pointer.

In the absence of a standard I'd be inclined to say no, by the way.  I 
generally don't like chaining APIs :)  So, my word should not be considered 
final on this, it's just my opinion, and "don't echo an argument" is indeed a 
generally observed rule in Python APIs, as far as I can tell.

--

___
Python tracker 

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



[issue33326] Convert collections (cmp_op, hasconst, hasname and others) in opcode module to more optimal type

2018-04-26 Thread Kirill Balunov

Kirill Balunov  added the comment:

Small risk of breaking is a fair point (maybe some FutureWarning with new 
__getattr__ PEP 562?). I've checked several packages:

---
vstinner/bytecode:: uses:

@staticmethod
def _has_jump(opcode):
return (opcode in _opcode.hasjrel
or opcode in _opcode.hasjabs)

---
maynard:: defines them as sets and does not rely on opcode module.

all_jumps = absolute_jumps | relative_jumps

---
numba:: converts them to frozensets:

JREL_OPS = frozenset(dis.hasjrel)
JABS_OPS = frozenset(dis.hasjabs)
JUMP_OPS = JREL_OPS | JABS_OPS

---
codetransfromer:: uses:

absjmp = opcode in hasjabs
reljmp = opcode in hasjrel

---
anotherassembler.py:: uses

elif opcode in hasjrel or opcode in hasjabs:

---
byteplay:: converts them to set:

hasjrel = set(Opcode(x) for x in opcode.hasjrel)
hasjabs = set(Opcode(x) for x in opcode.hasjabs)
hasjump = hasjrel.union(hasjabs)

---
byterun:: uses:

elif byteCode in dis.hasjrel:
arg = f.f_lasti + intArg
elif byteCode in dis.hasjabs:
arg = intArg

In fact, all of the above indicated does not mean anything, but I have not 
found cases of hasjrel+hasjabs.

Despite the fact that they are small, on average, with sets I gain 5-6x 
speed-up.

--

___
Python tracker 

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



[issue33326] Convert collections (cmp_op, hasconst, hasname and others) in opcode module to more optimal type

2018-04-26 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

This list are short. I don't think there is a large benefit of this change. But 
there is a small risk of breaking a third party code (for example 
hasjrel+hasjabs).

--

___
Python tracker 

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



[issue33368] Inaccuracy in https://docs.python.org/3/library/re.html#re.match.end

2018-04-26 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

It returns not the index of the last character of the substring, but the index 
of the end of the substring, i.e. the position past the last character of the 
substring.

Try s[:sre.end()] and s[sre.end():].

s[sre.begin()] gives you the part of s before the matched substring, 
s[sre.begin():sre.end()] gives you the matched substring itself (the same as 
sre.group()) and s[sre.end():] gives you the part of s after the matched 
substring.

--
nosy: +serhiy.storchaka
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue33326] Convert collections (cmp_op, hasconst, hasname and others) in opcode module to more optimal type

2018-04-26 Thread Kirill Balunov

Change by Kirill Balunov :


--
nosy: +larry, serhiy.storchaka

___
Python tracker 

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



[issue21822] KeyboardInterrupt during Thread.join hangs that Thread

2018-04-26 Thread Eryk Sun

Eryk Sun  added the comment:

For POSIX systems, try the following test function several times. For the bug 
to manifest, Thread._wait_for_tstate_lock has to be interrupted in between 
acquiring and releasing the sentinel lock. Maybe it could use a reentrant lock 
in order to avoid this problem.

import os
import signal
import threading
import time

def raise_sigint():
print('raising SIGINT')
time.sleep(0.5)
if os.name == 'nt':
os.kill(0, signal.CTRL_C_EVENT)
else:
os.kill(os.getpid(), signal.SIGINT)
print('finishing')

def test(f=raise_sigint):
global g_sigint
g_sigint = threading.Thread(target=f, name='SIGINT')
g_sigint.start()
print('waiting')
for i in range(100):
try:
if not g_sigint.is_alive():
break
g_sigint.join(0.01)
except KeyboardInterrupt:
print('KeyboardInterrupt ignored')
print('g_sigint is alive:', g_sigint.is_alive())

POSIX-only code normally wouldn't join() with a small timeout in a loop as in 
the above example. This is a workaround for the problem that's demonstrated in 
msg221180, in which a signal doesn't interrupt a wait on the main thread. Other 
than time.sleep(), most waits in Windows CPython have not been updated to 
include the SIGINT Event object when waiting in the main thread. (It's possible 
to fix some cases such as waiting on locks, but only as long as the 
implementation continues to use semaphores and kernel waits instead of native 
condition variables with SRW locks.)

--
nosy: +eryksun

___
Python tracker 

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



[issue32455] PyCompile_OpcodeStackEffect() and dis.stack_effect() are not particularly useful

2018-04-26 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

I concur with Kirill and was going to propose this change in a separate issue.

--

___
Python tracker 

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



[issue32455] PyCompile_OpcodeStackEffect() and dis.stack_effect() are not particularly useful

2018-04-26 Thread Kirill Balunov

Kirill Balunov  added the comment:

Sorry if this doesn't fit this issue and needs a separate one.

Since Python switched to 2 byte wordcode, all opcodes which do not imply an 
argument, technically have it - augmented with 0. So it is convenient to 
iterate over bytecode like:

op, arg = instruction.

But there is a check in stack_effect that the second argument for this opcodes 
must be None. 

file::_opcode.c

else if (oparg != Py_None) {
PyErr_SetString(PyExc_ValueError,
"stack_effect: opcode does not permit oparg but oparg was 
specified");
return -1;
}


So you need to perform a somewhat _redundant_ check before calling:

arg = arg if op >= opcode.HAVE_ARGUMENT else None.
st = stack_effect(op, arg)

Maybe it's normal to relax this condition - be None or 0 for opcode < 
opcode.HAVE_ARGUMENT?

--
nosy: +godaygo

___
Python tracker 

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



[issue21822] KeyboardInterrupt during Thread.join hangs that Thread

2018-04-26 Thread Paul Goins

Paul Goins  added the comment:

Not sure if I'll do the full fix (need to check w/ my employer), but I'm doing 
some investigation.  Here's what I know so far:

At the Python level, the KeyboardInterrupt is being raised within 
_wait_for_tstate_lock, on "elif lock.acquire(block, timeout)".

Going into the C code, it looks like this goes through 
lock_PyThread_acquire_lock -> acquire_timed -> PyThread_acquire_lock_timed.  
acquire_timed .  lock_PyThread_acquire_lock will abort the lock if it receives 
PY_LOCK_INTR from acquire_timed.

My best guess right now is that PyThread_acquire_lock_timed never returns 
PY_LOCK_INTR.  Indeed, I see this comment at the top of the NT version of that 
function:

/* Fow now, intr_flag does nothing on Windows, and lock acquires are
 * uninterruptible.  */

And indeed, the thread_pthread.h implementations both have a path for returning 
PY_LOCK_INTR, while the thread_nt.h version does not.

...And that's where I am thus far.

--

___
Python tracker 

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



[issue33368] Inaccuracy in https://docs.python.org/3/library/re.html#re.match.end

2018-04-26 Thread C. Y. Hollander

New submission from C. Y. Hollander :

The documentation states that match.end([group]) returns "the ind[ex] of the... 
end of the substring matched by group". In fact, it returns [said index] + 1, 
as demonstrated by the example below:

s = 'example'
sre = re.search('le', s)
s[sre.end()]

Incidentally, I don't see the logic of this behaviour, but in any case it 
should be correctly documented.

--
assignee: docs@python
components: Documentation
messages: 315813
nosy: C. Y. Hollander, docs@python
priority: normal
severity: normal
status: open
title: Inaccuracy in https://docs.python.org/3/library/re.html#re.match.end
type: enhancement

___
Python tracker 

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



[issue33000] IDLE Doc: Text consumes unlimited RAM, consoles likely not

2018-04-26 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

Big Stone: thank you for the clarification that IDLEX, and its patching of 
idlelib, is not involved.   WinPython is an independent augmented distribution. 
Your suggestion about its IDLEX icon should be sent to its authors.

--

___
Python tracker 

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



[issue33361] readline() + seek() on io.EncodedFile breaks next readline()

2018-04-26 Thread Diego Argueta

Diego Argueta  added the comment:

Update: If I run your exact code it still breaks for me:

```
Got header: 'abc\n'
Skipping the header. 'def\n'
Line 2: 'ghi\n'
Line 3: 'abc\n'
Line 4: 'def\n'
Line 5: 'ghi\n'
```

I'm running Python 2.7.14 and 3.6.5 on OSX 10.13.4. Startup banners:

Python 2.7.14 (default, Feb  7 2018, 14:15:12) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin

Python 3.6.5 (default, Apr  2 2018, 14:03:12) 
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)] on darwin

--

___
Python tracker 

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



[issue33361] readline() + seek() on io.EncodedFile breaks next readline()

2018-04-26 Thread Diego Argueta

Diego Argueta  added the comment:

That's because the stream isn't transcoding, since UTF-8 is ASCII-compatible. 
Try using something not ASCII-compatible as the codec e.g. 'ibm500' and it'll 
give incorrect results.

```
b = io.BytesIO(u'a,b\r\n"asdf","jkl;"\r\n'.encode('ibm500'))
s = codecs.EncodedFile(b, 'ibm500')
```

```
Got header: '\x81k\x82\r%'
Skipping the header. '\x7f\x81\xa2\x84\x86\x7fk\x7f\x91\x92\x93^\x7f\r%'
Line 2: '\x81k\x82\r%'
Line 3: '\x7f\x81\xa2\x84\x86\x7fk\x7f\x91\x92\x93^\x7f\r%'
```

--

___
Python tracker 

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



[issue33338] [lib2to3] Synchronize token.py and tokenize.py with the standard library

2018-04-26 Thread Łukasz Langa

Łukasz Langa  added the comment:

I agree with you Serhiy, there's a number things I want to make faster. But 
first I'd like to merge implementations so there is a clear one-way diff ("this 
is what we updated in lib2to3 to make it consistent it Lib/tokenize.py").  Then 
I want to optimize.

--

___
Python tracker 

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



[issue33000] IDLE Doc: Text consumes unlimited RAM, consoles likely not

2018-04-26 Thread Big Stone

Big Stone  added the comment:

WinPython-64bit-3.6.4.0Qt5b4 doesn't in fact includes IDLEX: IDLEX is not 
compatible with Python-3.6+

The "IDLEX" icon of WinPython switches back to "normal" IDLE, when IDLEX is not 
detected. 

As WinPython-3.5 is being deprecated, the icon should be renamed IDLE.

(see also https://bugs.python.org/issue17535 quest)

--
nosy: +Big Stone

___
Python tracker 

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



[issue33341] python3 fails to build if directory or sysroot contains "*icc*" string

2018-04-26 Thread Gianfranco

Gianfranco  added the comment:

I signed the contributor agreement, even if such patches shouldn't need any 
kind of license

--

___
Python tracker 

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



[issue33367] Multiprocessing Pool workers initiated with maxtasksperchild do not execute when sharing logging

2018-04-26 Thread Soumyadipta Das

New submission from Soumyadipta Das :

When Multiprocessing Pool is initiated with maxtasksperchild and is sharing 
logging with the root process some workers do not execute. This  is only on 
Python 2.7 and not on Python 3. Also bug is present only on linux and not on 
windows.

--
files: bugdemo.py
messages: 315804
nosy: Soumyadipta Das
priority: normal
severity: normal
status: open
title: Multiprocessing Pool workers initiated with maxtasksperchild do not 
execute when sharing logging
type: behavior
versions: Python 2.7
Added file: https://bugs.python.org/file47551/bugdemo.py

___
Python tracker 

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



[issue33366] `contextvars` documentation incorrectly refers to "non-local state".

2018-04-26 Thread Yury Selivanov

Yury Selivanov  added the comment:

I like what you propose. Can you submit a PR? :)

--

___
Python tracker 

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



[issue33358] [EASY] x86 Ubuntu Shared 3.x: test_embed.test_pre_initialization_sys_options() fails

2018-04-26 Thread Cheryl Sabella

Change by Cheryl Sabella :


--
assignee:  -> csabella
nosy: +csabella
stage:  -> needs patch

___
Python tracker 

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



[issue33338] [lib2to3] Synchronize token.py and tokenize.py with the standard library

2018-04-26 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

It seems to me that regular expressions used in the lib2to3 version are more 
efficient but more complex.

$ ./python -m timeit -s 'import re; p = re.compile(r"0[bB](?:_?[01])+"); s = 
"0b"+"_0101"*16' 'p.match(s)'
10 loops, best of 5: 2.45 usec per loop

$ ./python -m timeit -s 'import re; p = re.compile(r"0[bB]_?[01]+(?:_[01]+)*"); 
s = "0b"+"_0101"*16' 'p.match(s)'
20 loops, best of 5: 1.08 usec per loop

$ ./python -m timeit -s 'import re; p = 
re.compile(r"0[xX](?:_?[0-9a-fA-F])+[lL]?"); s = "0x_0123_4567_89ab_cdef"' 
'p.match(s)'
50 loops, best of 5: 815 nsec per loop

$ ./python -m timeit -s 'import re; p = 
re.compile(r"0[xX]_?[\da-fA-F]+(?:_[\da-fA-F]+)*[lL]?"); s = 
"0x_0123_4567_89ab_cdef"' 'p.match(s)'
50 loops, best of 5: 542 nsec per loop

Since the performance of lib2to3 is important, it is better to keep the current 
regexpes.

But using \d in Python 3 is a bug, it should be replaced with [0-9]. This also 
speeds up the regex:

$ ./python -m timeit -s 'import re; p = 
re.compile(r"0[xX]_?[0-9a-fA-F]+(?:_[0-9a-fA-F]+)*[lL]?"); s = 
"0x_0123_4567_89ab_cdef"' 'p.match(s)'
50 loops, best of 5: 471 nsec per loop

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue32797] Tracebacks from Cython modules no longer work

2018-04-26 Thread Erik Bray

Erik Bray  added the comment:

+1, that seems obvious to me like better behavior.

--

___
Python tracker 

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



[issue33280] Update link to Tcl/Tk 8.6 man pages in tkinter.rst

2018-04-26 Thread Andrés Delfino

Andrés Delfino  added the comment:

There's still an open PR to backport this to 3.6:

https://github.com/python/cpython/pull/6602

--

___
Python tracker 

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



[issue33280] Update link to Tcl/Tk 8.6 man pages in tkinter.rst

2018-04-26 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:


New changeset 4533494ac553273239c809053b54c0ab783a0c78 by Serhiy Storchaka 
(Andrés Delfino) in branch '3.6':
[3.6] bpo-33280: Reorganize external Tcl/Tk references. (GH-6473). (#6602)
https://github.com/python/cpython/commit/4533494ac553273239c809053b54c0ab783a0c78


--

___
Python tracker 

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



[issue33280] Update link to Tcl/Tk 8.6 man pages in tkinter.rst

2018-04-26 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



[issue33358] [EASY] x86 Ubuntu Shared 3.x: test_embed.test_pre_initialization_sys_options() fails

2018-04-26 Thread STINNER Victor

STINNER Victor  added the comment:

To reproduce the bug:

./configure --with-pydebug --enabled-shared
make clean
make
LD_LIBRARY_PATH=$PWD ./python -m test -v test_embed

--

___
Python tracker 

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



[issue33358] [EASY] x86 Ubuntu Shared 3.x: test_embed.test_pre_initialization_sys_options() fails

2018-04-26 Thread STINNER Victor

STINNER Victor  added the comment:

It seems like the failure comes from "env = 
dict(PYTHONPATH=os.pathsep.join(sys.path))" of Lib/test/test_embed.py. The code 
from test_pre_initialization_api() works properly. The fix seems easy.

--
keywords: +easy
title: x86 Ubuntu Shared 3.x: test_embed.test_pre_initialization_sys_options() 
fails -> [EASY] x86 Ubuntu Shared 3.x: 
test_embed.test_pre_initialization_sys_options() fails

___
Python tracker 

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



[issue33280] Update link to Tcl/Tk 8.6 man pages in tkinter.rst

2018-04-26 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:


New changeset 1c6c8510f91fcd9d46a8ce9155d8c2689d7df92b by Serhiy Storchaka 
(Andrés Delfino) in branch '2.7':
[2.7] bpo-33280: Reorganize external Tcl/Tk references. (GH-6473). (GH-6607)
https://github.com/python/cpython/commit/1c6c8510f91fcd9d46a8ce9155d8c2689d7df92b


--

___
Python tracker 

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



[issue20104] expose posix_spawn(p)

2018-04-26 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

What about posix_spawnp()? The title mentions both functions, but I don't see 
any mentions about posix_spawnp() in the discussion. Its omission looks 
unintentional to me.

--

___
Python tracker 

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



[issue31141] Start should be a keyword argument of the built-in sum

2018-04-26 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

In 2.6 it was "sequence".

--

___
Python tracker 

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



[issue31141] Start should be a keyword argument of the built-in sum

2018-04-26 Thread STINNER Victor

STINNER Victor  added the comment:

> I don't think it is worth to allow passing the first argument as a keyword 
> argument.

I concur. Would you mind to add a test to make sure that passing the first 
argument as the "iterable" keyword doesn't work?

"iterable" name comes from the Doc/library/functions.rst documentation and from 
the docstring.

--
nosy: +vstinner

___
Python tracker 

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



[issue33366] `contextvars` documentation incorrectly refers to "non-local state".

2018-04-26 Thread Tom Christie

New submission from Tom Christie :

The `contextvars` documentation, at 
https://docs.python.org/3.7/library/contextvars.html starts with the following:

"This module provides APIs to manage, store, and access non-local state."

I assume that must be a documentation bug, right. The module isn't for managing 
non-local state, it's for managing state that *is* local.

I'd assume it ought to read...

"This module provides APIs to manage, store, and access context-local state."

(ie. for managing state that is transparently either thread-local or task-local 
depending on the current execution context.)

--
assignee: docs@python
components: Documentation, asyncio
messages: 315792
nosy: asvetlov, docs@python, tomchristie, yselivanov
priority: normal
severity: normal
status: open
title: `contextvars` documentation incorrectly refers to "non-local state".
type: enhancement
versions: Python 3.7, Python 3.8

___
Python tracker 

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



[issue31141] Start should be a keyword argument of the built-in sum

2018-04-26 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

First than to allow this argument be passes by keyword, we mast choose its 
name. See the discussion "Start argument for itertools.accumulate()" on 
Python-ideas 
(https://mail.python.org/pipermail/python-ideas/2018-April/049649.html).

--

___
Python tracker 

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



[issue33365] http/client.py does not print correct headers in debug

2018-04-26 Thread Marco Strigl

Change by Marco Strigl :


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

___
Python tracker 

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



[issue31155] Encode set, frozenset, bytearray, and iterators as json arrays

2018-04-26 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

There is some virtue to the current design.  Having a user explicitly cast to a 
list will avoid unintentional conversions.

--
nosy: +rhettinger

___
Python tracker 

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



[issue31141] Start should be a keyword argument of the built-in sum

2018-04-26 Thread Cheryl Sabella

Cheryl Sabella  added the comment:

Hi Mark,

Are you able to make the Argument Clinic change the Serhiy suggested to come up 
with new benchmarks?  

Thanks!

--
nosy: +csabella

___
Python tracker 

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



[issue33361] readline() + seek() on io.EncodedFile breaks next readline()

2018-04-26 Thread Elena Oat

Elena Oat  added the comment:

I cannot replicate this when the stream is:

In: stream_ex = io.BytesIO(u"abc\ndef\nghi\n".encode("utf-8"))
In: f = codecs.EncodedFile(stream_ex, 'utf-8')

In: run(f)

Out: Got header: b'abc\n'
Skipping the header: b'abc\n'
Line 2: b'def\n'
Line 3: b'ghi\n'

--
nosy: +Elena.Oat

___
Python tracker 

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



[issue33365] http/client.py does not print correct headers in debug

2018-04-26 Thread Marco Strigl

New submission from Marco Strigl :

Consider the following script: 

try:
from urllib import request
except ImportError:
import urllib2 as request

handler = request.HTTPSHandler(debuglevel=1)
opener = request.build_opener(handler)
f = opener.open('https://httpbin.org/user-agent')


In python2.x this works: 

$ python2 http_client_bug.py
send: 'GET /user-agent HTTP/1.1\r\nAccept-Encoding: identity\r\nHost:
httpbin.org\r\nConnection: close\r\nUser-Agent: Python-urllib/2.7\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
header: Connection: close
header: Server: gunicorn/19.7.1
header: Date: Thu, 26 Apr 2018 12:01:35 GMT
header: Content-Type: application/json
header: Access-Control-Allow-Origin: *
header: Access-Control-Allow-Credentials: true
header: X-Powered-By: Flask
header: X-Processed-Time: 0
header: Content-Length: 40
header: Via: 1.1 vegur


But in python3.x only the header keys are printed. Not the values (also a 
newline after each header will be nice):

$ python3 http_client_bug.py
send: b'GET /user-agent HTTP/1.1\r\nAccept-Encoding: identity\r\nHost:
httpbin.org\r\nUser-Agent: Python-urllib/3.6\r\nConnection: close\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
header: Connection header: Server header: Date header: Content-Type
header: Access-Control-Allow-Origin header:
Access-Control-Allow-Credentials header: X-Powered-By header:
X-Processed-Time header: Content-Length header:

Patch for this is attached.

--
components: Library (Lib)
files: complete_pretty_headers.patch
keywords: patch
messages: 315787
nosy: mstrigl
priority: normal
severity: normal
status: open
title: http/client.py does not print correct headers in debug
versions: Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8
Added file: https://bugs.python.org/file47550/complete_pretty_headers.patch

___
Python tracker 

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



[issue9625] argparse: Problem with defaults for variable nargs when using choices

2018-04-26 Thread Freek Dijkstra

Change by Freek Dijkstra :


--
nosy: +macfreek

___
Python tracker 

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



[issue32455] PyCompile_OpcodeStackEffect() and dis.stack_effect() are not particularly useful

2018-04-26 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


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



[issue32455] PyCompile_OpcodeStackEffect() and dis.stack_effect() are not particularly useful

2018-04-26 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

In 3.7 the stack effect is calculated more accurately by the compiler. PR 6610 
exposes this feature to users. It add jump parameter to dis.stack_effect() and 
to PyCompile_OpcodeStackEffect(). By default the maximal value is returned. 
Passing jump=True for a non-jumping code or passing jump=False to RETURN_VALUE 
or JUMP_ABSOLUTE don't raise an exception and don't return a special value. It 
is up to the caller to pass reliable arguments.

This will make the workaround for stack_effect() in the bytecode project [1] 
not needed in 3.8.

[1] https://github.com/vstinner/bytecode/pull/29

--

___
Python tracker 

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



[issue32455] PyCompile_OpcodeStackEffect() and dis.stack_effect() are not particularly useful

2018-04-26 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue32790] Keep trailing zeros in precision for string format option g

2018-04-26 Thread Cheryl Sabella

Change by Cheryl Sabella :


--
keywords: +easy
stage:  -> needs patch
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



[issue22069] TextIOWrapper(newline="\n", line_buffering=True) mistakenly treat \r as a newline

2018-04-26 Thread Elena Oat

Change by Elena Oat :


--
keywords: +patch
pull_requests: +6305
stage: needs patch -> patch review

___
Python tracker 

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



[issue22069] TextIOWrapper(newline="\n", line_buffering=True) mistakenly treat \r as a newline

2018-04-26 Thread Elena Oat

Elena Oat  added the comment:

Note that the correct link to the test case is:
https://github.com/python/cpython/blob/master/Lib/test/test_io.py#L2565

--
nosy: +Elena.Oat

___
Python tracker 

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



[issue33284] Increase test coverage for numbers.py

2018-04-26 Thread Barry Devlin

Barry Devlin  added the comment:

Hey,

I updated my pull request based in your advice. Could you review it please?

Best,

Barry

On Sat, 21 Apr 2018, 03:20 Terry J. Reedy,  wrote:

>
> Terry J. Reedy  added the comment:
>
> Barry, thank you for your first submission.
>
> You propose to test numbers.Complex.__bool__
>
> def __bool__(self):
> """True if self != 0. Called for bool(self)."""
> return self != 0
>
> by adding the following to Lib/test/test_abstract_numbers.
>
> +self.assertFalse(bool(complex(0,0)))
> +self.assertTrue(bool(complex(1,2)))
>
> I believe that this particular addition should be rejected.  It is a
> concrete test of the builtin complex that partially duplicates the
> following in test_complex.
>
> def test_boolcontext(self):
> for i in range(100):
> self.assertTrue(complex(random() + 1e-6, random() + 1e-6))
> self.assertTrue(not complex(0.0, 0.0))
>
> Looking the tests of collections.abc in test_collections, I believe a
> proper test should define a subclass of Complex (in Python), with at least
> __init__ and __eq__ methods and test instances of *that*.
>
> If I were to review a patch, I would like to see a more extensive
> addition, one that imports test_collections.ABCTestCase (or copies and
> adapts the same) and uses it to test a much fuller implementation of
> Complex.  As it is, none of the numbers abc class methods are tested.
>
> Raymond, were you involved with the abc tests? Either way, what do you
> think?
>
> --
> nosy: +rhettinger, terry.reedy
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue27227] argparse fails to parse [] when using choices and nargs='*'

2018-04-26 Thread Freek Dijkstra

Freek Dijkstra  added the comment:

I don't think that this issue27227 and issue9625 are the same (although they 
may have the same root cause, and I would be in favour of fixing both issues). 
At least, I think the unit test are distinct:

This issue27227 is that argparse does not accept 0 options is '0 or more' are 
specified in nargs. Issue9625 is that argparse returns a different type if a 
default is specified or when it is not.

So I propose to reopen this ticket: it is not fixed, and different from the 
referred ticket.

--
nosy: +macfreek
versions: +Python 3.7

___
Python tracker 

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



[issue31155] Encode set, frozenset, bytearray, and iterators as json arrays

2018-04-26 Thread Ori Avtalion

Ori Avtalion  added the comment:

If sets are to be supported, then so should dictionary views.

Please also consider the range type.

--
nosy: +salty-horse

___
Python tracker 

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



[issue33364] Conditionals not evaluating propertly

2018-04-26 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

In Python "True == False < 20" is evaluated as "True == False and False < 20". 
See https://docs.python.org/3/reference/expressions.html#comparisons

--
nosy: +serhiy.storchaka
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue33360] ALternative recipe for password using secrets

2018-04-26 Thread Juan Postlbauer

Juan Postlbauer  added the comment:

Just a clarification: by "infinite potential loop" I meant a loop that 
*theoretically* could last forever. Of course in practice it won't, but my 
experiments show that for the conditions in the example in average the current 
recipe generates 5 tentative passwords before finding one that fulfills all 
conditions.

--

___
Python tracker 

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



[issue33364] Conditionals not evaluating propertly

2018-04-26 Thread Juan Enrique Segebre Zaghmout

New submission from Juan Enrique Segebre Zaghmout :

The following code generates False when it should generate true:

True == False < 20

Either way the order of operation is taken should result in True but the answer 
still results in False. To further confirm this issue I did a simple test in 
which we would group the operations, the test uses print statements to 
visualize results. The short following code represents the above conditional 
and the two order of operations possibilities.

print(True == False < 20);
print((True == False) < 20);
print(True == (False < 20));

This yields the following output:

False
True
True

Proving the bug. To explain even further, the code shall be interpreted in 
either of the following two ways:
1. True == False < 20
   False < 20
   True

2. True == False < 20
   True == True
   True

In either case the result is True, yet python yields False.

--
components: Interpreter Core
messages: 315779
nosy: Segebre
priority: normal
severity: normal
status: open
title: Conditionals not evaluating propertly
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



[issue31455] ElementTree.XMLParser() mishandles exceptions

2018-04-26 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


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