[issue33469] RuntimeError after closing loop that used run_in_executor

2018-05-12 Thread Hrvoje Nikšić

New submission from Hrvoje Nikšić :

Looking at a StackOverflow question[1], I was unable to find a way to correctly 
close an event loop that uses run_in_executor() for long-running tasks.

The question author tried to implement the following scenario:

1. create some tasks that use run_in_executor
2. run asyncio.wait(tasks, return_when=FIRST_EXCEPTION)
3. cancel pending tasks, if any
4. close the loop and continue with non-async work

However, when there are pending tasks from wait(), a RuntimeError is raised 
some time after step #4. In the test programs, it happens while waiting for the 
program to finish. I have attached a minimal example to reproduce the issue.

The immediate cause is that a callback installed by wrap_future() notices that 
the underlying concurrent.futures.Future is done and calls 
loop.call_soon_threadsafe() to copy the result to the asyncio.Future. 
call_soon_threadsafe() fails when the loop is closed.

This would be reasonable behavior if not for the fact that the code explicitly 
cancelled the asyncio future, and awaited it to ensure that the cancellation 
took effect. While it is clear that asyncio cannot interrupt a function already 
running in an executor, it should probably detach the connection between the 
concurrent future and the asyncio future, to prevent this kind of error (and 
possibly other problems).

For example, the _call_check_cancel closure in _chain_future could remove (or 
disable) the done_callback installed on source after the call to 
source.cancel(). Since at that point we know that destination (asyncio.Future) 
is already canceled, there is no longer value in invoking the done callback for 
source (concurrent.futures.Future).


[1]
https://stackoverflow.com/q/50279522/1600898

--
files: executor-cancel
messages: 316420
nosy: hniksic
priority: normal
severity: normal
status: open
title: RuntimeError after closing loop that used run_in_executor
versions: Python 3.6, Python 3.7
Added file: https://bugs.python.org/file47583/executor-cancel

___
Python tracker 

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



[issue33470] Changes from GH-1638 (GH-3575, bpo-28411) are not documented in Porting to Python 3.7

2018-05-12 Thread Miro Hrončok

New submission from Miro Hrončok :

Background: gdb fails to build with Python 3.7 as described in 
https://bugzilla.redhat.com/show_bug.cgi?id=1577396

This is due to _PyImport_FixupBuiltin changing it's API. I feel that 
_underscored functions are probably not guaranteed to not change, however I 
miss anything about the following changes:

https://github.com/python/cpython/pull/1638
https://github.com/python/cpython/pull/3565
https://github.com/python/cpython/pull/3575

In here:

https://docs.python.org/3.7/whatsnew/3.7.html#porting-to-python-37
(or that page generally)

That page doesn't mention PyInterpreterState at all, so even if you decide that 
_PyImport_FixupBuiltin doesn't deserve a mention, maybe the general change does.

Thanks

--
assignee: docs@python
components: Documentation
messages: 316421
nosy: docs@python, eric.snow, hroncok, vstinner
priority: normal
severity: normal
status: open
title: Changes from GH-1638 (GH-3575, bpo-28411) are not documented in Porting 
to Python 3.7
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



[issue29209] Remove old-deprecated ElementTree features

2018-05-12 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

getchildren() and getiterator() have deprecation notes in their docstrings in 
lxml.etree.

--

___
Python tracker 

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



[issue29209] Remove old-deprecated ElementTree features

2018-05-12 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
pull_requests: +6457

___
Python tracker 

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



[issue29209] Remove old-deprecated ElementTree features

2018-05-12 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

PR 6769 removes the html parameter and the doctype() method. getchildren() and 
getiterator() emit now a DeprecationWarning instead of 
PendingDeprecationWarning and will be removed in 3.9.

--

___
Python tracker 

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



[issue29209] Remove old-deprecated ElementTree features

2018-05-12 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

The following two patches will remove getchildren() and getiterator() (in 3.9) 
and xml.etree.cElementTree (in an unspecified future).

--
Added file: 
https://bugs.python.org/file47584/etree_remove_deprecated_getiterator.diff

___
Python tracker 

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



[issue29209] Remove old-deprecated ElementTree features

2018-05-12 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


Added file: 
https://bugs.python.org/file47585/etree_remove_deprecated_cElementTree.diff

___
Python tracker 

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



[issue29209] Remove old-deprecated ElementTree features

2018-05-12 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



[issue33427] Dead link in "The Python Standard Library" page

2018-05-12 Thread Ned Deily

Ned Deily  added the comment:

Note that while the link in the docs should be updated, the old link should 
redirect properly.  That change has been requested in 
https://github.com/pypa/warehouse/issues/3914

--
nosy: +ned.deily

___
Python tracker 

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



[issue33471] string format with 'n' failling with french locales

2018-05-12 Thread David Vasseur

New submission from David Vasseur :

Python 3.6.5 (default, Apr 14 2018, 13:17:30) 
[GCC 7.3.1 20180406] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print('{:n}'.format(int(12)))
12 <-- ok --

>>> import locale
>>> locale.setlocale(locale.LC_ALL, '')
'fr_FR.UTF-8'
>>> print('{:n}'.format(int(12)))
(empty) <-- error --
'{:n}'.format(int(12))
'Àæ' <-- error --

please note that with >999 numbers, it's working fine:
>>> print('{:n}'.format(int(1000)))
1 000 <-- ok --

--
components: Extension Modules
messages: 316426
nosy: David Vasseur
priority: normal
severity: normal
status: open
title: string format with 'n' failling with french locales
type: behavior
versions: Python 3.6

___
Python tracker 

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



[issue33442] Python 3 doc sidebar dosnt follow page scrolling like 2.7 doc sidebar.

2018-05-12 Thread Ned Deily

Change by Ned Deily :


--
nosy: +ezio.melotti, georg.brandl

___
Python tracker 

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



[issue23607] Inconsistency in datetime.utcfromtimestamp(Decimal)

2018-05-12 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
assignee:  -> serhiy.storchaka
priority: normal -> low
versions: +Python 3.8 -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



[issue33470] Changes from GH-1638 (GH-3575, bpo-28411) are not documented in Porting to Python 3.7

2018-05-12 Thread STINNER Victor

STINNER Victor  added the comment:

Miro: do you want to work on a pull request?

--

___
Python tracker 

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



[issue33470] Changes from GH-1638 (GH-3575, bpo-28411) are not documented in Porting to Python 3.7

2018-05-12 Thread STINNER Victor

STINNER Victor  added the comment:

Is it a release blocker?

--
nosy: +ned.deily
priority: normal -> release blocker

___
Python tracker 

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



[issue33472] build system incorrectly handles CC, CFLAGS, LDFLAGS, and related.

2018-05-12 Thread Eitan Adler

New submission from Eitan Adler :

There are a number of incorrect items in python's build system. 

Expected behavior:
- CC is correctly report as the compiler, and without any additional options
- CFLAGS is correctly reported for the required flags to the compiler
- CXXFLAGS is the same as CFLAGS, but for C++
- LDFLAGS is correctly report for linker flags

Actual behavior:
- CC is reported as a non-existing compiler plus an option
- C*FLAGS and LDFLAGS are not correctly reported

--
components: Build
messages: 316429
nosy: Eitan Adler
priority: normal
pull_requests: 6458
severity: normal
status: open
title: build system incorrectly handles CC, CFLAGS, LDFLAGS, and related.
type: compile error

___
Python tracker 

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



[issue33472] build system incorrectly handles CC, CFLAGS, LDFLAGS, and related.

2018-05-12 Thread Eitan Adler (bad account)

Eitan Adler (bad account)  added the comment:

closing this as I created under a bad account and can't find a way to merge 
them.

--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue33473] build system incorrectly handles CC, CFLAGS, LDFLAGS, and related.

2018-05-12 Thread Eitan Adler

New submission from Eitan Adler :

There are a number of incorrect items in python's build system. 

Expected behavior:
- CC is correctly report as the compiler, and without any additional options
- CFLAGS is correctly reported for the required flags to the compiler
- CXXFLAGS is the same as CFLAGS, but for C++
- LDFLAGS is correctly report for linker flags

Actual behavior:
- CC is reported as a non-existing compiler plus an option
- C*FLAGS and LDFLAGS are not correctly reported

--
components: Build
messages: 316431
nosy: eitan.adler
priority: normal
pull_requests: 6459
severity: normal
status: open
title: build system incorrectly handles CC, CFLAGS, LDFLAGS, and related.
type: compile error

___
Python tracker 

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



[issue33463] Can namedtuple._asdict return a regular dict instead of OrderedDict?

2018-05-12 Thread Michael Selik

Change by Michael Selik :


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

___
Python tracker 

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



[issue33463] Can namedtuple._asdict return a regular dict instead of OrderedDict?

2018-05-12 Thread Michael Selik

Michael Selik  added the comment:

Is this warning what you had in mind?
https://github.com/python/cpython/pull/6772

--

___
Python tracker 

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



[issue4934] tp_del and tp_version_tag undocumented

2018-05-12 Thread book book

book book  added the comment:

tp_del still undocumented.

In my opinion, tp_del corresponds to the __del__() method of classes, because 
there are no other variable correspondes to it, but methods using for 
creating(tp_new) and initializing(tp_init) an object are not.

Although __del__ method have some issue according to the offical document, but 
it is exist, so there must have a pointer to the function corresponding to it.

--
nosy: +book book
versions: +Python 3.6 -Python 2.6, Python 2.7, Python 3.2, Python 3.3, Python 
3.4

___
Python tracker 

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



[issue4934] tp_del and tp_version_tag undocumented

2018-05-12 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

The reason tp_del has remained undocumented is that it's now obsolete.  You 
should use tp_finalize instead:
https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_finalize

tp_finalize is roughly the C equivalent of __del__ (tp_del was something else, 
despite the name).

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



[issue4934] tp_del and tp_version_tag undocumented

2018-05-12 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Both tp_del and tp_version_tag are for internal use.  Besides, tp_del is 
obsolete as I mentioned above.  So I'm going to close the issue.

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



[issue33462] reversible dict

2018-05-12 Thread Rémi Lapeyre

Rémi Lapeyre  added the comment:

Hi, I'm taking a look this issue, it look like a new type 
`PyDictRevIterKey_Type` needs to be defined with its associated methods. I will 
try to implement the modifications ; this is the first time i'm taking a dive 
in Python's internals so I can't guarantee results on this but will try 
nonetheless.

--
nosy: +remi.lapeyre

___
Python tracker 

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



[issue33462] reversible dict

2018-05-12 Thread Michael Selik

Michael Selik  added the comment:

Right, a blend of the code from dictiterobject 
(https://github.com/python/cpython/blob/master/Objects/dictobject.c#L3309) and 
listreviterobject 
(https://github.com/python/cpython/blob/master/Objects/listobject.c#L3128).

--

___
Python tracker 

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



[issue33474] Support immutability per-field in dataclasses

2018-05-12 Thread Daniel Lindeman

New submission from Daniel Lindeman :

Currently, all fields in dataclasses can be frozen by passing frozen=True to 
the decorator. There are cases where it would be useful to have some fields be 
mutable, and others immutable. By using a strategy similar to how the decorator 
frozen works, using __setattr__ and __delattr__, it would be possible to 
support immutability per-field. This could perhaps be done by adding a frozen 
argument to the field constructor.

--
messages: 316438
nosy: Daniel Lindeman, eric.smith
priority: normal
severity: normal
status: open
title: Support immutability per-field in dataclasses
type: enhancement
versions: Python 3.7

___
Python tracker 

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



[issue33475] Fix converting AST expression to string and optimize parenthesis

2018-05-12 Thread Serhiy Storchaka

New submission from Serhiy Storchaka :

The proposed patch fixes bugs in ast_unparse.c, makes it generating cleaner 
string representation, and makes the code cleaner.

Known fixed bugs:

1. Extended slices crash Python. "s[a, b:c]".

2. 1-tuples produce illegal syntax: "(a,)" => "(, a)".

3. Lambdas in f-strings produce illegal syntax. "f'{(lambda x: x)}'" => 
"f'{lambda x: x}'".

4. Some expressions that need parenthesis don't have them. E.g. "lambda x: (x, 
x)" => "lambda x: x, x".

5. Generators and yield expression always must be surrounded with parenthesis. 
"(x for x in y)" => "x for x in y", "(yield)" => "yield".

6. Top-level tuples must be surrounded with parenthesis. "(a, b)" => "a, b".

Produced string representation is now more clean and almost not contains 
redundant parenthesis.

"(a + b) * (c + d)" => "(a + b) * (c + d)"
"(a * b) + (c * d)" => "a * b + c * d"
"(a * b) * (c * d)" => "a * b * (c * d)"
"(a ** b) ** (c ** d)" => "(a ** b) ** c ** d"
"[(a + b)]" => "[a + b]"
"[(i ** 2) for i in range(1, (a + 1))]" => "[i ** 2 for i in range(1, a + 1)]"

Maybe other bugs were fixed in process.

And finally I use macros for simple repeated fragments of code like

if (-1 == append_charp(writer, str)) {
return -1;
}

This made the meaningful code much shorter and saved around 250 lines of code.

--
components: Interpreter Core
messages: 316439
nosy: lukasz.langa, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Fix converting AST expression to string and optimize parenthesis
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



[issue33475] Fix converting AST expression to string and optimize parenthesis

2018-05-12 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue33475] Fix converting AST expression to string and optimize parenthesis

2018-05-12 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
nosy: +gvanrossum

___
Python tracker 

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



[issue33476] String index out of range in get_group(), email/_header_value_parser.py

2018-05-12 Thread Enrique Perez-Terron

New submission from Enrique Perez-Terron :

When address group is missing final ';', 'value' will be an empty string. I 
suggest the following patch

$ diff -u _save_header_value_parser.py _header_value_parser.py
--- _save_header_value_parser.py2018-03-14 01:07:54.0 +0100
+++ _header_value_parser.py 2018-05-13 02:17:13.830053600 +0200
@@ -1876,7 +1876,7 @@
 if not value:
 group.defects.append(errors.InvalidHeaderDefect(
 "end of header in group"))
-if value[0] != ';':
+elif value[0] != ';':
 raise errors.HeaderParseError(
 "expected ';' at end of group but found {}".format(value))
 group.append(ValueTerminal(';', 'group-terminator'))

--
components: email
messages: 316440
nosy: Cacadril, barry, r.david.murray
priority: normal
severity: normal
status: open
title: String index out of range in get_group(), email/_header_value_parser.py
type: crash
versions: Python 3.6

___
Python tracker 

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



[issue33477] Document that compile(code, 'exec') has different behavior in 3.7+

2018-05-12 Thread Matthias Bussonnier

New submission from Matthias Bussonnier :

In recent Python the following 

>>> from ast import PyCF_ONLY_AST
>>> compile("'a'", 'whatever', 'exec', PyCF_ONLY_AST).body

In 3.6 it return

   [<_ast.Expr at 0x10b7441d0>] # that contail Str('a')

While on master:

   []

This is inconveninent for alternative repl like IPython, where basically if the 
user is entering a single string, the result is nothing in Python 3.7+, while 
it _does_ return something on earlier Python [1]. 

The documentation of `compile` says:

>  ... it can be 'exec' if source consists of a sequence of statements,

Which is not technically true any more as the first statement, if a string, 
will be removed. 

What's happening here is that since Python 3.7 if the _first_ statement is 
actually an expression containing a lonely string it is assign to the module 
docstring. So that's basically assuming you are parsing a module, and that the 
docstring make sens in this context, while in a REPL you are parsing a 
sucesssion of statements, in which case there is no need for a docstring that 
make no sens in this context.


This is _usually_ not an issue, unless this lonely statement is also the last, 
and what the user wants to execute in a REPL, in which case it has no side 
effect.

I don't have any objection to the new behavior, though I was wondering if this 
kind of side effect was anticipated. 

If that affect IPython, it will likely effect other alternative REPLs.

Thus, I believe it would be good to have this at least documented a tiny bit 
better and added in what's new, and potentially clarified in the `exec` docs.

I could argue that now the  `exec` name may be a tiny bit unsuitable for the 
new behavior, and would love if this could be optional.

1: https://github.com/ipython/ipython/issues/11133#issuecomment-388591332

--
assignee: docs@python
components: Documentation, Interpreter Core
messages: 316441
nosy: docs@python, mbussonn
priority: normal
severity: normal
status: open
title: Document that compile(code, 'exec') has different behavior in 3.7+
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



[issue33453] from __future__ import annotations breaks dataclasses ClassVar and InitVar handling

2018-05-12 Thread Ivan Levkivskyi

Change by Ivan Levkivskyi :


--
nosy: +levkivskyi

___
Python tracker 

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



[issue33471] string format with 'n' failling with french locales

2018-05-12 Thread Eric V. Smith

Eric V. Smith  added the comment:

After locale.setlocale(locale.LC_ALL, ''), what does local.localeconv() return?

--
nosy: +eric.smith

___
Python tracker 

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



[issue33470] Changes from GH-1638 (GH-3575, bpo-28411) are not documented in Porting to Python 3.7

2018-05-12 Thread Miro Hrončok

Miro Hrončok  added the comment:

The change is a bit beyond my understanding ATM. I might be able to study it 
and stitch something up, but I'd rather leave it to the author of the change.

--

___
Python tracker 

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



[issue30928] Copy modified blurbs to idlelib/NEWS.txt for 3.7.0

2018-05-12 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

Testing undocumented issue.message reference I remember seeing somewhere: 
#11077.msg183774, #11077.183774

--

___
Python tracker 

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



[issue30928] Copy modified blurbs to idlelib/NEWS.txt for 3.7.0

2018-05-12 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

I was looking for a way to link to a message in the context of an issue rather 
that on a page by itself.  Neither worked.

--

___
Python tracker 

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



[issue33478] PEP 8 CapWords reference wrong?

2018-05-12 Thread Amit Saha

New submission from Amit Saha :

PEP 8 suggests class names and type variable names to be in CapWords case. 
However:

>>> import string
>>> string.capwords('CapWord')
'Capword'

Wondering if this this an oversight or am I misunderstanding something?

--
assignee: docs@python
components: Documentation
messages: 316446
nosy: Amit.Saha, docs@python
priority: normal
severity: normal
status: open
title: PEP 8 CapWords reference wrong?

___
Python tracker 

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



[issue33479] Document tkinter and threads

2018-05-12 Thread Terry J. Reedy

New submission from Terry J. Reedy :

(Proposed patch below)

Library Reference Chapter 25, Graphical User Interfaces with Tk, covers tinter, 
some of its subpackages, and IDLE.  The introduction, 
https://docs.python.org/3/library/tk.html states "the internal module _tkinter 
provides a threadsafe mechanism which allows Python and Tcl to interact."  Or 
as Martin Loewis claimed, "Tkinter is thread-safe." (#11077, msg127979).

Unfortunately, the unqualified 'threadsafe' claim is not true.  If Tcl is 
compiled with thread support (the default for 8.6) worker thread calls work 
(for the examples I have tested).  If not (the default for 8.5 and before), 
they are unreliable and can fail in multiple ways.  Known factors include the 
number of worker threads making call, the type of calls, and the number of 
calls.

The deceptive claim and the lack of knowledge about the crucial role of how tcl 
is compiled has negative effects.  First, people who have non-thread tcl have 
suffered trying to deal with random failures.  (See issues listed in #11077, 
msg183774, and #33257.)   Second, non-coredev tkinter experts have spread the 
equally wrong claim that 'tkinter is not threadsafe".  (See the same message.)  
So people who have do have thread tcl are discouraged from exploiting the fact.

I suggest

1. Remove 'threadsafe' from the intro sentence.  After it, add "See  for more details." <..> indicates a link to the proposed new 
section below.

2. The tkinter section itself, https://docs.python.org/3/library/tkinter.html, 
currently says nothing about threads.  I propose to add a new subsection, 
location to be decided.
"""
Tkinter and threads.

If you want to use both tkinter and threads, the safest method is to make all 
tkinter calls in the main thread.  If worker threads generate data needed for 
tkinter calls, use a queue.Queue to send the data to the main thread.  For a 
clean shutdown, add a method to wait for threads to stop and have it called 
when the window close button [X] is pressed.

If you are using Tcl/Tk compiled with thread support, you can skip the queue 
and call tkinter methods in the worker threads.  To avoid deadlocks when 
shutting down, you may have to join working threads in a separate 'join' thread 
that does not make tkinter calls.

If you are using Tcl/Tk compiled without thread support, tkinter calls in 
worker threads may initially work, but may eventually fail somewhat randomly.  
Known factors include the number of threads, the type of call, and the number 
of calls.

To determine whether your tcl/tk has thread support, look in 
/Lib/DLLs for files such as, tcl86(t).dll and tk86(t).dll (The 
tcl/tk version would then be '8.6'.)  The t for 'thread' suffix is present or 
absent as tcl/tk was compiled with or without thread support.



"""

--
messages: 316447
nosy: serhiy.storchaka, terry.reedy
priority: normal
severity: normal
stage: patch review
status: open
title: Document tkinter and threads
type: behavior
versions: Python 2.7, 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



[issue16823] Python quits on running tkinter code with threads

2018-05-12 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

In the message above, I asked "why this code runs in 3.x but eventually fails 
in 2.x?".  The answer is almost certainly that I used 3.5 with tk 8.6 compiled 
*with* thread support and 2.7 with tk 8.5 compiled without thread support.

Serhiy, if you use a system supplied 8.6 with thread support for all Python 
versions, that would explain why these thread examples work for you with all 
Python versions.  If non-thread tk works for you, then the code in _tkinter.c 
works better on Linux (where it must have been developed) than Windows.

The original failure report duplicates other similar reports.  My previous 
responses, including proposed doc change were incomplete, as I only learned 
about the tcl compile option a month ago.  I opened #33479, with more extensive 
proposed tkinter doc changes, in favor of this.

--
stage:  -> resolved
status: open -> closed
superseder:  -> Document tkinter and threads

___
Python tracker 

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



[issue11077] Tkinter is not thread safe

2018-05-12 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

The information missing from this issue is that tcl and tk can be compiled 
without and with thread support, and that the latter became default in 8.6, 
which is included with recent 3.x versions.  Hence the launch example, as 
posted on #33257, works for me in 3.7 but not 2.7.

I opened tkinter doc issue 33479, with this additional info, as a followup to 
msg183774 above.

--

___
Python tracker 

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



[issue33479] Document tkinter and threads

2018-05-12 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

The information about the compile option comes from Ivan Pozdeev, #33257.  I 
meant to add somewhere that thread support became default only with tk 8.6.

--

___
Python tracker 

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



[issue33257] Race conditions in Tkinter with non-threaded Tcl

2018-05-12 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

I opened #33479 Document tkinter and threads, as a spinoff of both this issue 
and #11077, msg183774.

--

___
Python tracker 

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



[issue6933] Threading issue with Tkinter Frame.insert

2018-05-12 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

I changes the import to theading instead of thread and the start line to
threading.Thread(target=example)
On 3.7 with tcl/tk 8.6 with thread support, I see the gui when mainloop is 
called in the thread, and then the >>> prompt appears.  On 2.7 with tk 8.5 
without thread support, I see no hang but only >>>, no box, after the same time 
delay.  

With thread support, thread calls work.  Without, success varies, and so do 
failure modes.  See #33479 for proposed doc on tkinter and thread safety.

--

___
Python tracker 

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



[issue16823] Python quits on running tkinter code with threads

2018-05-12 Thread Terry J. Reedy

Change by Terry J. Reedy :


--
resolution:  -> duplicate

___
Python tracker 

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



[issue33474] Support immutability per-field in dataclasses

2018-05-12 Thread Raymond Hettinger

Change by Raymond Hettinger :


--
assignee:  -> eric.smith
components: +Library (Lib)
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



[issue33478] PEP 8 CapWords reference wrong?

2018-05-12 Thread Berker Peksag

Berker Peksag  added the comment:

'CapWord' is a single word so string.capwords() works as documented:

Split the argument into words using str.split(), capitalize each word
using str.capitalize(), and join the capitalized words using str.join().

https://docs.python.org/3/library/string.html#string.capwords

You can also see this in the REPL:

>>> "CapWord".split()
['CapWord']
>>> _[0].capitalize()  # '_' is a shortcut for the latest command
'Capword'

--
nosy: +berker.peksag
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

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