[issue23926] skipitem() in getargs.c still supports 'w' and 'w#', and shouldn't

2018-07-08 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
components: +Interpreter Core
versions: +Python 3.7, Python 3.8 -Python 3.5

___
Python tracker 

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



[issue23926] skipitem() in getargs.c still supports 'w' and 'w#', and shouldn't

2018-07-08 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Do you mind to convert your patch into a pull request Joe?

--

___
Python tracker 

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



[issue34073] asyncio and ProcessPoolExecutor: OSError on loop.close()

2018-07-08 Thread Julien Palard


Julien Palard  added the comment:

Can reproduce with 3.7.0 on Linux.

--
nosy: +mdk

___
Python tracker 

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



[issue17180] shutil copy* unsafe on POSIX - they preserve setuid/setgit bits

2018-07-08 Thread Larry Hastings


Larry Hastings  added the comment:

I'll accept this into 3.4 and 3.5, if someone produces a PR and someone else 
reviews it.  Given that the issue has already celebrated its fifth birthday I 
can't say I feel a lot of urgency about it.

--

___
Python tracker 

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



[issue34073] asyncio and ProcessPoolExecutor: OSError on loop.close()

2018-07-08 Thread Jon Banafato


New submission from Jon Banafato :

Calling loop.close() on an eventloop configured to use a ProcessPoolExecutor 
can result in an OSError.

Expected behavior: no exception raised.
Actual behavior: an OSError is raised, and following this call, quit() fails to 
terminate the process gracefully. 

Example:

Python 3.8.0a0 (default, Jul  7 2018, 14:35:49)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncio
>>> from concurrent.futures import ProcessPoolExecutor
>>> import os
>>>
>>> loop = asyncio.get_event_loop_policy().new_event_loop()
>>> loop.set_default_executor(ProcessPoolExecutor())
>>> future = loop.run_in_executor(None, os.getpid)
>>> loop.run_until_complete(future)
24697
>>> loop.close()
Exception ignored in: .weakref_cb at 
0x7f52e7f643f0>
Traceback (most recent call last):
  File "/code/Lib/concurrent/futures/process.py", line 567, in weakref_cb
thread_wakeup.wakeup()
  File "/code/Lib/concurrent/futures/process.py", line 89, in wakeup
self._writer.send_bytes(b"")
  File "/code/Lib/multiprocessing/connection.py", line 183, in send_bytes
self._check_closed()
  File "/code/Lib/multiprocessing/connection.py", line 136, in _check_closed
Exception in thread QueueManagerThread:
Traceback (most recent call last):
  File "/code/Lib/threading.py", line 917, in _bootstrap_inner
self.run()
  File "/code/Lib/threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
  File "/code/Lib/concurrent/futures/process.py", line 368, in 
_queue_management_worker
thread_wakeup.clear()
  File "/code/Lib/concurrent/futures/process.py", line 92, in clear
while self._reader.poll():
  File "/code/Lib/multiprocessing/connection.py", line 255, in poll
self._check_closed()
  File "/code/Lib/multiprocessing/connection.py", line 136, in _check_closed
raise OSError("handle is closed")
OSError: handle is closed

raise OSError("handle is closed")
OSError: handle is closed

--
components: Library (Lib), asyncio
messages: 321297
nosy: asvetlov, jonafato, yselivanov
priority: normal
severity: normal
status: open
title: asyncio and ProcessPoolExecutor: OSError on loop.close()
type: behavior
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



[issue28778] wsgiref HTTP Response Header Injection: CRLF Injection

2018-07-08 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
versions:  -Python 3.3

___
Python tracker 

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



[issue17180] shutil copy* unsafe on POSIX - they preserve setuid/setgit bits

2018-07-08 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Should the patch be turned into a PR or should this be closed?

--
nosy: +terry.reedy
versions:  -Python 3.2, Python 3.3

___
Python tracker 

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



[issue31623] Build MSI installer for 3.4 security releases on Windows

2018-07-08 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

If we cannot test this and will not merge without testing*, then perhaps we 
should close it rather than pretend it still has a chance.

*Which I think would be a bad idea.

In any case, I made the title specific enough so that this issue and patch 
might possibly be discovered by someone wanting to do what Ivan claims the 
patch allows.

--
nosy: +terry.reedy
stage:  -> test needed
title: Allow to build MSI installer from the official tarball -> Build MSI 
installer for 3.4 security releases on Windows

___
Python tracker 

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



[issue34072] 3.7.0 Windows embeddable zip vcruntime140.dll

2018-07-08 Thread hyu


New submission from hyu :

3.7.0 Windows embeddable zip is missing vcruntime140.dll(?)
Running python would display error about VCRUNTIME140.DLL.
Copying vcruntime140.dll from earlier 3.6.x release is a work around.

--
components: Windows
messages: 321294
nosy: hyu, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: 3.7.0 Windows embeddable zip vcruntime140.dll
type: behavior
versions: Python 3.7

___
Python tracker 

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



[issue34071] repr(task) raises AssertionError for coros which loop.create_task accepts; complications ensue

2018-07-08 Thread Jim DeLaHunt


Jim DeLaHunt  added the comment:

This is what I observe when I run my original program with Python 3.7.0. Notice 
that the Task object instantiation fails with a clear error message:

% python -c 'import sys; print(sys.version)'
3.7.0 (default, Jun 28 2018, 06:01:52) 
[Clang 8.0.0 (clang-800.0.42.1)]

% python bug_task_repr_1.py
type(ag()) is  
asyncio.iscoroutine(ag)?  False
repr(ag()) is  
Traceback (most recent call last):
  File "bug_task_repr_1.py", line 42, in 
task = asyncio.get_event_loop().create_task(ag())
  File 
"/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py",
 line 386, in create_task
task = tasks.Task(coro, loop=self)
TypeError: a coroutine was expected, got 

Also, the unit test example fails due to asyncio.test_utils no longer being 
present in Python 3.7.0. 

I am comfortable with a workaround of upgrading to 3.7.0 or later for anyone 
who encounters this problem. 

I file this bug report mostly to let people who encounter this problem find 
this report in web searches, to help them understand the cause, and  to see the 
workaround (patching Task._repr_info) if upgrading to 3.7 is not feasible.

--

___
Python tracker 

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



[issue34071] repr(task) raises AssertionError for coros which loop.create_task accepts; complications ensue

2018-07-08 Thread Jim DeLaHunt


New submission from Jim DeLaHunt :

In Python 3.6.5, Task.__repr__() with raise an AssertionError for 
certain, arguably incorrect, coroutines which the instantiation of Task() 
accepts. repr(task) thus fails with an AssertionError, instead of
returning a string which describes the task object and why its coroutine 
is wrong. Complications ensue. 

In particular, if this Task is used in a unittest.TestCase, and appears in test 
failure diagnostics, the test
diagnostics are discarded when the AssertionError occurs, masking the 
problem in the code under test. 

In Python 3.7.0, Task.__init__() checks the supplied coroutine argument,
using the same asyncio.iscoroutine() method which Task.__repr__() calls.
Thus, while repr(task) can still raise an AssertionError, it is much harder to 
reach this situation. Task.__init__() is likely to raise an exception first, 
and the diagnostics will be pretty clear.

To reproduce:

1. Here is a simple, perhaps misguided, attempt at a coroutine, and a Task 
which uses it:

import asyncio

async def ag():
yield None

print("type(ag()) is ", type(ag()))
print("asyncio.iscoroutine(ag)? ", asyncio.iscoroutine(ag))
print("repr(ag()) is ", repr(ag()))

task = asyncio.get_event_loop().create_task(ag())
print("type(task) is ", type(task))
print("asyncio.iscoroutine(task._coro)? ", asyncio.iscoroutine(task._coro))
print("repr(task) is ")
print(repr(task))

The output from Python 3.6.5 is:
type(ag()) is  
asyncio.iscoroutine(ag)?  False
repr(ag()) is  
type(task) is  
asyncio.iscoroutine(task._coro)?  False
repr(task) is 
Traceback (most recent call last):
  File "bug_task_repr_1.py", line 31, in 
print(repr(task))
  File 
"/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/base_tasks.py",
 line 15, in _task_repr_info
coro = coroutines._format_coroutine(task._coro)
  File 
"/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/coroutines.py",
 line 276, in _format_coroutine
assert iscoroutine(coro)
AssertionError

Observed behaviour: 

Here is a unit test which attempts to exercise the above Task. The test fails, 
but the AssertionError in Task.__repr__() discards the error diagnostics:

from asyncio import test_utils
 
class Test(test_utils.TestCase):

def setUp(self):
super().setUp()
self.loop = self.new_test_loop()

def test_wrongly_scheduled(self):
# this is a simple, and maybe mistaken, coroutine
async def ag():
yield None

_ = self.loop.create_task(ag())
test_utils.run_once(self.loop)

The output from Python 3.6.5 is:

% python -m unittest bug_task_repr_2.py
Exception in default exception handler
Traceback (most recent call last):
  File 
"/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/base_events.py",
 line 1291, in call_exception_handler
self.default_exception_handler(context)
  File 
"/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/base_events.py",
 line 1263, in default_exception_handler
value = repr(value)
  File 
"/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/base_tasks.py",
 line 15, in _task_repr_info
coro = coroutines._format_coroutine(task._coro)
  File 
"/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/coroutines.py",
 line 276, in _format_coroutine
assert iscoroutine(coro)
AssertionError
.
--
Ran 1 test in 0.001s
 
OK

Note that the error traceback is all about the exception from Task.__repr__(), 
and the diagnostics about why the unit test failed is discarded.

Expected behaviour:

Here is the same unit test, but this time with a replacement method for 
Task._task_repr_info() which avoids the AssertionError. 

import asyncio
from asyncio import test_utils
import types

class Test(test_utils.TestCase):

def setUp(self):
super().setUp()
self.loop = self.new_test_loop()

def test_wrongly_scheduled(self):
# this is a simple, and maybe mistaken, coroutine
async def ag():
yield None

task = self.loop.create_task(ag())
task._repr_info = types.MethodType( task_safe_repr_info, task )
test_utils.run_once(self.loop)


def task_safe_repr_info(self):
'''task.task_safe_repr_info(): string list representation of task. Won't 
raise AssertionError

If you have a Task object which is raising an AssertionError from 
"assert iscoroutine(coro)", then assign to instantiated object:
task._repr_info = task_safe_repr_info
Patched task object should be able to survive the AssertionError and 
deliver a useful representation.
'''
try:
# from Task._repr_info(self), which calls 
base_tasks._task_repr_info(self)
info = asyncio.base_futures._future_repr_info(self)

if self._must_canc

[issue24665] CJK support for textwrap

2018-07-08 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I think that this issue should be closed, as it is based on some confusions and 
errors.

Textwrap works in terms of characters.  The wrap method "wraps the single 
paragraph in text (a string) so every line is at most width characters long."  
When the module was written, 'character' meant "printable ascii (or 'extended 
ascii') character".  It now means 'unicode codepoint'.  Both are mentally real 
abstractions but have no particular correspondence to physical length.  Calling 
textwrap buggy because it works in characters is wrong.

Translating 'character' to 'fixed-width character space', so that one can 
measure physical length in terms of 'spaces' as a physical unit, is exact if 
and only if all characters are displayed in the same width space.  This is true 
for fixed pitch output devices that simulate typewriters and text that only 
used fixed-width characters from a fixed pitch font.  For long lines, the 
translation for a variable-pitch fonts may or may not be good enough for a 
particular use.

As David noted, textwrap already fails for Ascii control characters.  And it 
does cause problem when they are used in wrapped text. They are coded with 2 or 
4 characters on input and may display as 0, 1, (possibly 2), 4, or 5 characters 
on output, depending on the display code and the display 'device'.  As to the 
latter, "print('x\ax')" displays as 'xx' in a Windows console and as  something 
like xx in a tkinter Text widget, except that the numbers in the box here on 
Firefox are not present, so that the tk box is (sort-of) the same width as 'x'.

The particular premise of this issue is that CJK characters are somehow special 
and that 2.x releases, and now 3.x releases, are particularly broken for CJK 
text.  Not so.  If one has text that only uses same-width characters in a 
fixed-pitch CJK font (including wide spaces so columns line up), then textwrap 
works as well as it does for any other fixed-pitch text (ie, Ascii or Latin1).  
If one wants lines of a particular physical width, one passes a character width 
argument that corresponds to the desired physical width.

The following is based on what I see in IDLE's Settings dialog Font page font 
sample for Windows 10 'Source Code Pro'.  It includes samples from 12 
'alphabet's  To view it, run 'python -m idlelib', and on the top menu click 
Options => Configure IDLE.  When the selected font is not a full BMP unicode 
font, Tk and Windows use other fonts, scaled to the same height, to synthesize 
a fairly complete BMP 'font'.  The [Help] text says a bit more but has a 
mistake.  What I see:

Font size corresponds to physical height.  Hence, the lines are very close to 
the same height.  Some fonts look smaller or larger because they specify more 
or less blank space between lines.  One factor is the use of descenders, as in 
Arabic.

Character width for a fixed height varies.  20 characters in Greek, IPA, 
Hebrew, and Arabic take progressive less physical space than 20 Ascii or Latin1 
characters.  20 characters in Devanagari, Cyrillic, and Tamil take 
progressively more. (The Tamil line only has 14 chars.)  None of these are 
obviously fixed pitch.

The Chinese, Korean, and Japanese samples have a fixed pitch.  The characters 
are *not* actually 'double-wide', at least no relative to most other languages. 
 The 10 CJK characters are as wide as 16 Source Code Pro characters.  To match 
the physical width of 72 Ascii spaces, one should pass 'width=45'.

But note that the exact ratio for Ascii depends on the font. It is a little 
higher for Courier and Lucida Console.  It ranges from about 1 (for Arabic) to 
2 (for Tamil) for other languages.  The first 10 Tamil characters are slightly 
wider than the 10 CJK characters, so counting each CJK character as two average 
Tamil character is completely wrong.

My conclusion: the proposal is unnecessary for pure CJK text; it is wrong in 
hard-coding a fix only for CJK; the CJK fix is wrong in hard-coding a 
particular ratio, in particular, one that is at the extreme end of the range of 
possibilities.  Therefore, I think the open PR should be closed.  I also think 
this issue should be closed in favor of #12499, which proposed to allow users 
to pass a transform function suitable for their particular use case.  If that 
is implemented, and we decide to then add some sample functions, or rather, 
function factories, and to include one specifically for CJK*, then a new PR 
will be needed,  and a new issue would be appropriate.

* A more generic function factory for text with characters of two width classes 
might have as inputs a condition to identify '2nd language characters' and 
their fixed or average width relative relative to the 'first' language.

--
nosy: +terry.reedy
title: Use unicodedata.east_asian_width in textwrap -> CJK support for textwrap

___
Python tracker 

__

[issue33346] Syntax error with async generator inside dictionary comprehension

2018-07-08 Thread Guido van Rossum


Change by Guido van Rossum :


--
nosy:  -gvanrossum

___
Python tracker 

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



[issue32782] ctypes: memoryview gives incorrect PEP3118 itemsize for array of length zero

2018-07-08 Thread Eric Wieser


Eric Wieser  added the comment:

Pinging, as recommended by https://devguide.python.org/pullrequest/#reviewing. 
Ideally this and https://bugs.python.org/issue32780 would make the same patch 
release.

--

___
Python tracker 

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



[issue25711] Rewrite zipimport from scratch

2018-07-08 Thread Brett Cannon


Brett Cannon  added the comment:

I'm planning to review the PR at some point.

On Sun, Jul 8, 2018, 00:42 Serhiy Storchaka,  wrote:

>
> Serhiy Storchaka  added the comment:
>
> Could anybody please make a review? This is just a first step, we need to
> do it before making other steps: implementing more modern import API,
> supporting large ZIP files and ZIP files with comments, implementing
> loading binary extensions from ZIP files, etc.
>
> --
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue34066] Possible resource warning in "with open()"

2018-07-08 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Maybe it is worth to disable interrupting before more opcodes. For example for 
fixing a problem with the contextlib.nullcontext example (issue34067) we need 
to disable interrupting before STORE_FAST, LOAD_FAST and JUMP_FORWARD.

--

___
Python tracker 

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



[issue33387] Simplify bytecodes for try-finally, try-except and with blocks.

2018-07-08 Thread Gregory P. Smith


Change by Gregory P. Smith :


--
nosy: +gregory.p.smith, ncoghlan, serhiy.storchaka

___
Python tracker 

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



[issue32949] Simplify "with"-related opcodes

2018-07-08 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

Additional related PR: https://github.com/python/cpython/pull/6641 tied to 
issue33387 which proposes replacing the existing with and try related bytecodes 
with two simpler ones: RERAISE and WITH_EXCEPT_FINISH.

--
nosy: +gregory.p.smith

___
Python tracker 

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



[issue32498] urllib.parse.unquote raises incorrect errormessage when string parameter is bytes

2018-07-08 Thread stein-k


stein-k  added the comment:

I have made the News Entry and created the Pull request as described here: 
https://devguide.python.org/pullrequest/. Should I update the Status and 
Resolution of the issue here, or wait for some kind of confirmation?

--

___
Python tracker 

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



[issue33346] Syntax error with async generator inside dictionary comprehension

2018-07-08 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

PR 6766 adds numerous examples of nesting async
generator expressions and comprehensions as tests.

--

___
Python tracker 

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



[issue24665] Use unicodedata.east_asian_width in textwrap

2018-07-08 Thread Julien Palard


Julien Palard  added the comment:

Hi Inada, you're right and that's more or less why I not used CJK in the 
implementation: mainly I don't want to close the door to future enhancements on 
this topic (char width) of non-CJK languages (like those "invisible hyphens" 
here only to tell textwrapers where they can wrap inside of words, and so on).

I'll remove CJK mentions (sadly maybe not today).

--

___
Python tracker 

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



[issue24665] Use unicodedata.east_asian_width in textwrap

2018-07-08 Thread INADA Naoki


Change by INADA Naoki :


--
title: CJK support for textwrap -> Use unicodedata.east_asian_width in textwrap
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



[issue24665] CJK support for textwrap

2018-07-08 Thread INADA Naoki

INADA Naoki  added the comment:

I'm not expert of this area, but Korean support is still totally broken:

>>> import unicodedata
>>> s = "\u1100\u1161\u11a8"
>>> unicodedata.east_asian_width(s[0])
'W'
>>> unicodedata.east_asian_width(s[1])
'N'
>>> unicodedata.east_asian_width(s[2])
'N'
>>> s
'각'
>>> s[:2]
'가'
>>> print(s[:2] + '\n' + s[2:])
가
ᆨ
>>> print(s[:1] + '\n' + s[1:])
ᄀ
ᅡᆨ


I think "CJK support" is not nice naming for just using east_asian_width.
PR-5649 doesn't use "CJK" word in APIs, but uses in commit log (PR title)
and NEWS entry.

Maybe, it should be "Textwrap now uses ``unicodedata.east_asian_width()``
to calculate text width when unicodedata is available."

--

___
Python tracker 

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



[issue34070] Superfluous call to isatty in open() when buffering >= 0

2018-07-08 Thread David Herberth


Change by David Herberth :


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

___
Python tracker 

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



[issue34070] Superfluous call to isatty in open() when buffering >= 0

2018-07-08 Thread David Herberth


New submission from David Herberth :

_iomodule.c:_io_open_impl checks for isatty even if not necessary (when 
buffering >= 0).

Code: 
https://github.com/python/cpython/blob/c0ee341b29bd7d978b49272a2c0e2dcfa77404d5/Modules/_io/_iomodule.c#L392

{
PyObject *res = _PyObject_CallMethodId(raw, &PyId_isatty, NULL);
if (res == NULL)
goto error;
isatty = PyLong_AsLong(res);
Py_DECREF(res);
if (isatty == -1 && PyErr_Occurred())
goto error;
}

if (buffering == 1 || (buffering < 0 && isatty)) {
buffering = -1;
line_buffering = 1;
}
else
line_buffering = 0;


Python Code to reproduce:

with open('foo', 'rb', buffering=0) as f:
f.read()


This generates an error (can be seen with strace):

ioctl(5, TCGETS, 0x7ffef1435b60)  = -1 ENOTTY (Inappropriate ioctl for device)

I'll open a PR shortly.

--
components: IO
messages: 321281
nosy: Dav1d
priority: normal
severity: normal
status: open
title: Superfluous call to isatty in open() when buffering >= 0
type: performance
versions: Python 3.6, 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



[issue32780] ctypes: memoryview gives incorrect PEP3118 format strings for both packed and unpacked structs

2018-07-08 Thread Alexander Belopolsky


Change by Alexander Belopolsky :


--
assignee:  -> belopolsky

___
Python tracker 

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



[issue32780] ctypes: memoryview gives incorrect PEP3118 format strings for both packed and unpacked structs

2018-07-08 Thread Alexander Belopolsky


Alexander Belopolsky  added the comment:

Unfortunately, the PEP authors did very little in terms of implementing the PEP 
and neither CPython nor numpy has a fully compliant implementation.

--
nosy: +aerojockey, teoliphant

___
Python tracker 

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



[issue32780] ctypes: memoryview gives incorrect PEP3118 format strings for both packed and unpacked structs

2018-07-08 Thread Eric Wieser


Eric Wieser  added the comment:

Pinging, as recommended by https://devguide.python.org/pullrequest/#reviewing. 
PEP3118 as a protocol is far less useful if the canonical implementation is 
non-compliant.

--

___
Python tracker 

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



[issue30400] Race condition in shutil.copyfile()

2018-07-08 Thread Giampaolo Rodola'


Giampaolo Rodola'  added the comment:

All copy* functions and move() are subjects to race conditions (the only 
exception is rmtree()). You may solve the race condition in copyfile() but then 
you'd have the same problem in copystat() and copymode() which are used by 
copy() and copy2(). The definitive solution to this problem would theoretically 
be to have all these interconnected functions pass fds instead of "paths" but 
of course that is hardly possible. Personally I don't think this issue is worth 
being fixed.

--

___
Python tracker 

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



[issue34061] Document sqlite3.NotSupportedError exception

2018-07-08 Thread Berker Peksag


Berker Peksag  added the comment:

Thanks, Marcin.

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



[issue34061] Document sqlite3.NotSupportedError exception

2018-07-08 Thread Berker Peksag


Berker Peksag  added the comment:


New changeset 0b63759651b366ddb4c1c1dece12ef776053d5ee by Berker Peksag (Marcin 
Niemira) in branch '3.7':
bpo-34061: Document sqlite3.NotSupportedError (GH-8172)
https://github.com/python/cpython/commit/0b63759651b366ddb4c1c1dece12ef776053d5ee


--

___
Python tracker 

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



[issue34061] Document sqlite3.NotSupportedError exception

2018-07-08 Thread Berker Peksag


Berker Peksag  added the comment:


New changeset 404156534893461165bb5b99a42cabe261dddb78 by Berker Peksag (Marcin 
Niemira) in branch '3.6':
bpo-34061: Document sqlite3.NotSupportedError (GH-8172)
https://github.com/python/cpython/commit/404156534893461165bb5b99a42cabe261dddb78


--

___
Python tracker 

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



[issue4963] mimetypes.guess_extension result changes after mimetypes.init()

2018-07-08 Thread Sascha Silbe


Change by Sascha Silbe :


--
nosy: +sascha_silbe

___
Python tracker 

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



[issue1043134] Add preferred extensions for MIME types

2018-07-08 Thread Sascha Silbe


Change by Sascha Silbe :


--
nosy: +sascha_silbe

___
Python tracker 

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



[issue34061] Document sqlite3.NotSupportedError exception

2018-07-08 Thread Marcin Niemira


Change by Marcin Niemira :


--
pull_requests: +7741

___
Python tracker 

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



[issue34061] Document sqlite3.NotSupportedError exception

2018-07-08 Thread Marcin Niemira


Change by Marcin Niemira :


--
pull_requests: +7740
stage: backport needed -> patch review

___
Python tracker 

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



[issue34069] shutil.move fails with AttributeError

2018-07-08 Thread Berker Peksag


Berker Peksag  added the comment:

This is a duplicate of bpo-32689.

> It should use `os.fspath(path)` to get the path as a string.

PR 5393 already does that.

--
nosy: +berker.peksag
resolution:  -> duplicate
stage: needs patch -> resolved
status: open -> closed
superseder:  -> shutil.move raises AttributeError if first argument is a 
pathlib.Path object and destination is a directory

___
Python tracker 

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



[issue34061] Document sqlite3.NotSupportedError exception

2018-07-08 Thread Berker Peksag


Change by Berker Peksag :


--
stage: patch review -> backport needed

___
Python tracker 

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



[issue34061] Document sqlite3.NotSupportedError exception

2018-07-08 Thread Berker Peksag


Berker Peksag  added the comment:


New changeset bc9aa813a34474e517af8999565ff6151559d42f by Berker Peksag (Marcin 
Niemira) in branch 'master':
bpo-34061: Document sqlite3.NotSupportedError (GH-8172)
https://github.com/python/cpython/commit/bc9aa813a34474e517af8999565ff6151559d42f


--

___
Python tracker 

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



[issue34069] shutil.move fails with AttributeError

2018-07-08 Thread Eryk Sun


Eryk Sun  added the comment:

This issue isn't specific to Windows. It's a bug in shutil._basename:


def _basename(path):
# A basename() variant which first strips the trailing slash, if 
present.
# Thus we always get the last component of the path, even for 
directories.
sep = os.path.sep + (os.path.altsep or '')
return os.path.basename(path.rstrip(sep))

It should use `os.fspath(path)` to get the path as a string.

--
components: +Library (Lib) -Windows
keywords: +easy
nosy: +eryksun
stage:  -> needs patch
title: Fail to move file in Windows (AttributeError) -> shutil.move fails with 
AttributeError
type:  -> behavior
versions: +Python 3.6, Python 3.8

___
Python tracker 

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



[issue34064] subprocess functions with shell=1 pass wrong command to win32 shell

2018-07-08 Thread Eryk Sun


Eryk Sun  added the comment:

This PR works around a bug in CMD, so I'm inclined to close it as a third-party 
issue. 

CMD is supposed to implement the following behavior:

1.  If all of the following conditions are met, then quote 
characters on the command line are preserved:

- no /S switch
- exactly two quote characters
- no special characters between the two quote characters,
  where special is one of: &<>()@^|
- there are one or more whitespace characters between the
  two quote characters
- the string between the two quote characters is the name
  of an executable file.

2.  Otherwise, old behavior is to see if the first character is
a quote character and if so, strip the leading character and
remove the last quote character on the command line, preserving
any text after the last quote character.

In particular quotes should only be preserved if the quoted string is "the name 
of an executable file". To determine this, CMD calls an internal function named 
SearchForExecutable. This function special cases any command that begins with 
"cmd " (case insensitive) by substituting the current value of the %ComSpec% 
environment variable for the *entire* string. Of course this search succeeds, 
so it ends up handling the string "cmd /c echo hello" as if it's an executable. 
Probably no has noticed this bug since running `cmd /c "cmd /c ..."` is kind of 
a weird thing to do.

To demonstrate this bug, let's compare running "cmd /c ..." with "cmd.exe /c 
...":

>>> subprocess.check_output('cmd /c "cmd /c echo hello"')
b'hello"\r\n'


>>> subprocess.check_output('cmd /c "cmd.exe /c echo hello"')
b'hello\r\n'

Adding /S makes CMD always use the old behavior that strips the quotes. 
However, this will change the existing behavior when the command line is an 
unquoted executable path with spaces in it. For example:

>>> sys.executable
'C:\\Program Files\\Python36\\python.exe'

>>> subprocess.call(sys.executable, shell=True)
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit 
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
0

With /S, CMD strips the quotes from the command. Without the quotes it parses 
"C:\Program" as the executable to run:

>>> subprocess.call('cmd /s /c "{}"'.format(sys.executable))
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
1

--
nosy: +eryksun
versions:  -Python 3.4, Python 3.5

___
Python tracker 

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



[issue34069] Fail to move file in Windows (AttributeError)

2018-07-08 Thread Joshua Avalon


New submission from Joshua Avalon :

from shutil import move
from pathlib import Path

a = Path("s")
b = Path("a.txt")

move(b, a)


This will throw AttributeError: 'WindowsPath' object has no attribute 'rstrip'

>From the document, it should able to move:

If the destination is an existing directory, then src is moved inside that 
directory. If the destination already exists but is not a directory, it may be 
overwritten depending on os.rename() semantics.

If a = Path("s/a.txt"), it does not throw error.

Enviroment:
  Window 10
  Python 3.7.0

--
components: Windows
messages: 321270
nosy: joshuaavalon, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Fail to move file in Windows (AttributeError)
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



[issue32788] Better error handling in sqlite3

2018-07-08 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +berker.peksag

___
Python tracker 

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



[issue33967] functools.singledispatch: Misleading exception when calling without arguments

2018-07-08 Thread Dong-hee Na


Change by Dong-hee Na :


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

___
Python tracker 

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



[issue30416] constant folding opens compiler to quadratic time hashing

2018-07-08 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Okay, this issue is fixed in 3.6.

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



[issue30416] constant folding opens compiler to quadratic time hashing

2018-07-08 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
priority: deferred blocker -> normal

___
Python tracker 

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



[issue31014] webbrowser._synthesize uses outdated calling signature for webbrowser.register

2018-07-08 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
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



[issue31014] webbrowser._synthesize uses outdated calling signature for webbrowser.register

2018-07-08 Thread miss-islington


miss-islington  added the comment:


New changeset a410f9f614b62cd7df220186d081ffd73786be91 by Miss Islington (bot) 
in branch '3.7':
bpo-31014: Fix the webbrowser module. (GH-7267)
https://github.com/python/cpython/commit/a410f9f614b62cd7df220186d081ffd73786be91


--
nosy: +miss-islington

___
Python tracker 

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



[issue25711] Rewrite zipimport from scratch

2018-07-08 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Could anybody please make a review? This is just a first step, we need to do it 
before making other steps: implementing more modern import API, supporting 
large ZIP files and ZIP files with comments, implementing loading binary 
extensions from ZIP files, etc.

--

___
Python tracker 

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



[issue31014] webbrowser._synthesize uses outdated calling signature for webbrowser.register

2018-07-08 Thread miss-islington


Change by miss-islington :


--
pull_requests: +7738

___
Python tracker 

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



[issue31014] webbrowser._synthesize uses outdated calling signature for webbrowser.register

2018-07-08 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 25b804a9c21c735ce322877f105ebab2539ccfc1 by Serhiy Storchaka in 
branch 'master':
bpo-31014: Fix the webbrowser module. (GH-7267)
https://github.com/python/cpython/commit/25b804a9c21c735ce322877f105ebab2539ccfc1


--

___
Python tracker 

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



[issue34047] IDLE: on macOS, scroll slider 'sticks' at bottom of file

2018-07-08 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

The text widget in IDLE is actually an instance of MulticallCreator(Text).  For 
tk_scroll2.py, I added the idlelib import and the call to MulticallCreator.

--
Added file: https://bugs.python.org/file47677/tk_scroll2.py

___
Python tracker 

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



[issue16822] execv (et al.) should invoke atexit handlers before executing new code

2018-07-08 Thread Tal Einat


Tal Einat  added the comment:

Seems like a decision needs to be made: Add support for `atexec` handlers, 
close this issue, or something else?

--

___
Python tracker 

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



[issue34041] add *deterministic* parameter to sqlite3.Connection.create_function()

2018-07-08 Thread Berker Peksag


Change by Berker Peksag :


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



[issue34068] Assertion failure in _PyType_Lookup

2018-07-08 Thread Stefan Behnel


Stefan Behnel  added the comment:

I added this assertion exactly for the purpose of finding this kind of bug. It 
means that some code tried to look up an attribute with a live exception set, 
which previously could swallow the exception in certain situations, and even if 
not, it is always the wrong thing to do.

Looking at the stack trace, my guess is that the problem is closer to the crash 
than the coverage calls. I'd suggest taking a look at the frame cleanup in the 
traceback module.

--
nosy: +scoder

___
Python tracker 

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



[issue34041] add *deterministic* parameter to sqlite3.Connection.create_function()

2018-07-08 Thread Berker Peksag


Berker Peksag  added the comment:


New changeset 0830858aeedecc9ece60349f8c31c2690d1a99f8 by Berker Peksag (Sergey 
Fedoseev) in branch 'master':
bpo-34041: Allow creating deterministic functions in 
Connection.create_function() (GH-8086)
https://github.com/python/cpython/commit/0830858aeedecc9ece60349f8c31c2690d1a99f8


--
nosy: +berker.peksag

___
Python tracker 

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