[issue32428] dataclasses: make it an error to have initialized non-fields in a dataclass

2017-12-26 Thread Eric V. Smith

Eric V. Smith  added the comment:

I'm not sure I understand the distinction. You have to look through everything 
in `__dict__`, then exclude those things that are any type of field (so, real 
fields or pseudo-fields). Those are the things that are in `__annotations__`, 
anyway.

The trick is what else to exclude.  In this class:

class C:
x: int = 0
y = 0

def func(self): pass

@staticmethod
def staticmeth() : pass

@classmethod
def classmeth(cls) : pass

@property
def prop(self): pass

These are the non-callables:

print([k for k in C.__dict__ if not callable(getattr(C, k))])

['__module__', '__annotations__', 'x', 'y', 'prop', '__dict__', '__weakref__', 
'__doc__']

How do we only pick out `y` and probably `prop`, and ignore the rest, without 
being overly fragile to new things being added? I guess ignoring dunders and 
things in `__annotations__`. Is that close enough?

--

___
Python tracker 

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



[issue32424] Rename copy() to __copy__() in xml.etree.ElementTree.Element Python implementation

2017-12-26 Thread Julien Palard

Julien Palard  added the comment:

As the C implementation is already shadowing the Python implementation when 
available (last lines of Lib/xml/etree/ElementTree.py), using `.copy()` is 
already a bug magnet (works when the Python implem is used, does not work when 
shadowed by the C implem).

So renaming the copy method to __copy__ in the python implementation looks good 
to me.

Ultimately the Python implementation would require a __deepcopy__ too?

--
nosy: +mdk

___
Python tracker 

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



[issue32429] Outdated Modules/Setup warning is invisible

2017-12-26 Thread Julien Palard

Julien Palard  added the comment:

> maintain your own branch with changes to a tracked file

Make sense for me, Xavier, would this fit your usage?

--

___
Python tracker 

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



[issue32429] Outdated Modules/Setup warning is invisible

2017-12-26 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> +1 - do you have any thoughts on that?

I think the current scheme may have been useful at a time where DVCS didn't 
exist.  You would maintain an unversioned copy of Modules/Setup.dist in your 
work-tree.  Nowadays you can fork a github repo and maintain your own branch 
with changes to a tracked file.  I don't think Modules/Setup deserves special 
treatment compared to, say, setup.py or Makefile.pre.in.

--

___
Python tracker 

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



[issue32428] dataclasses: make it an error to have initialized non-fields in a dataclass

2017-12-26 Thread Ivan Levkivskyi

Ivan Levkivskyi  added the comment:

A possible question here is should we give an error for any non-callable name 
in `__dict__` which is not in `__annotations__` or only for `Field`s?

After some thinking I am actually leaning towards the first option.

--
nosy: +gvanrossum, levkivskyi

___
Python tracker 

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



[issue32429] Outdated Modules/Setup warning is invisible

2017-12-26 Thread Julien Palard

Julien Palard  added the comment:

Antoine: I may take a look at this too.

Still, stopping in the Makefile looks a first trivial step toward not being 
screwed by it, removing it looks non trivial, will raise discussions, let's 
make it another issue?

--

___
Python tracker 

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



[issue32429] Outdated Modules/Setup warning is invisible

2017-12-26 Thread Barry A. Warsaw

Barry A. Warsaw  added the comment:

On Dec 26, 2017, at 18:17, Antoine Pitrou  wrote:
> 
> I'd really like it if we could get rid of the Setup/Setup.dist thing.  It's a 
> distraction to have to type `cp -f Modules/Setup.dist Modules/Setup` from 
> time to time... even though I have never customized the Setup file.

+1 - do you have any thoughts on that?

--

___
Python tracker 

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



[issue32429] Outdated Modules/Setup warning is invisible

2017-12-26 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

I'd really like it if we could get rid of the Setup/Setup.dist thing.  It's a 
distraction to have to type `cp -f Modules/Setup.dist Modules/Setup` from time 
to time... even though I have never customized the Setup file.

--
nosy: +barry, benjamin.peterson, pitrou

___
Python tracker 

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



[issue32416] Refactor and add new tests for the f_lineno setter

2017-12-26 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:


New changeset 53f9135667226f33e049e327db60fb033afbd77a by Serhiy Storchaka in 
branch 'master':
bpo-32416: Refactor tests for the f_lineno setter and add new tests. (#4991)
https://github.com/python/cpython/commit/53f9135667226f33e049e327db60fb033afbd77a


--

___
Python tracker 

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



[issue32429] Outdated Modules/Setup warning is invisible

2017-12-26 Thread Julien Palard

Change by Julien Palard :


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

___
Python tracker 

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



[issue32429] Outdated Modules/Setup warning is invisible

2017-12-26 Thread Julien Palard

New submission from Julien Palard :

The devguide advise to run `make -j`, why not, but in any cases between `make 
-j4` and `make -j` the warning:

---
Modules/Setup.dist is newer than Modules/Setup;
check to make sure you have all the updates you
need in your Modules/Setup file.
Usually, copying Modules/Setup.dist to Modules/Setup will work.
---

is invisible (gets on screen first, and get kicked real quick by the 
compilation lines).

This got me once, and I'm not alone: https://bugs.python.org/issue32335 (And I 
suspect we're more than just two).

I propose to make this stop the compilation, proposing two cases:

- You modified the file? Touch it so it gets seen as up to date by makefile
- You didn't modified it? Copy Modules/Setup.dist to Modules/Setup

Something like:

$ make
---
Modules/Setup.dist is newer than Modules/Setup;
check to make sure you have all the updates you
need in your Modules/Setup file.
Usually, copying Modules/Setup.dist to Modules/Setup will work.
Or if you want to keep your modifications, touch Modules/Setup
to skip this warning.
---
Makefile:703: recipe for target 'Modules/Setup' failed
make: *** [Modules/Setup] Error 1

--
assignee: mdk
components: Build
messages: 309066
nosy: mdk, xdegaye
priority: low
severity: normal
status: open
title: Outdated Modules/Setup warning is invisible
type: enhancement
versions: Python 2.7, Python 3.6, Python 3.7

___
Python tracker 

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



[issue32428] dataclasses: make it an error to have initialized non-fields in a dataclass

2017-12-26 Thread Eric V. Smith

New submission from Eric V. Smith :

For this class:

@dataclass
class C:
   x: int = 0
   y = 0

Generate a TypeError. 'y' is not a field (as defined by @dataclass). It should 
either be a regular field (by giving it a type annotation) or a ClassVar field.

--
assignee: eric.smith
components: Library (Lib)
messages: 309065
nosy: eric.smith
priority: normal
severity: normal
status: open
title: dataclasses: make it an error to have initialized non-fields in a 
dataclass
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



[issue32145] Wrong ExitStack Callback recipe

2017-12-26 Thread Barry A. Warsaw

Barry A. Warsaw  added the comment:

On Dec 25, 2017, at 18:51, Nick Coghlan  wrote:
> 
> 3. A for-subclasses-only "self._clone()" API could work as follows:
> 
>def _clone(self, new_instance=None):
>if new_instance is None:
>new_instance = type(self)()
># Clone state here
>return new_instance
> 
> Then subclasses could override *just* the instance creation part by doing:
> 
>def _clone(self):
>return super()._clone(self._make_instance())
> 
> While also being free to add their own additional state copying code if 
> needed.

So _make_instance() wouldn’t be part of ExitStack’s API, but subclasses could 
implement it (and name it whatever they want of course)?

I’m not sure _clone() is the right name here since that implies to me state 
copy as well, and I totally agree with your other points.  That’s why I 
originally suggested _make_instance() would be the name and API in the base 
class.

--

___
Python tracker 

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



[issue32427] Rename and expose dataclasses._MISSING

2017-12-26 Thread Eric V. Smith

New submission from Eric V. Smith :

There are occasions where you want to know the missing value, such as 
introspection and in cases like: Field(default=a if a is not None else 
_MISSING).

I'll rename _MISSING to MISSING.

--
assignee: eric.smith
components: Library (Lib)
messages: 309063
nosy: eric.smith
priority: normal
severity: normal
status: open
title: Rename and expose dataclasses._MISSING
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



[issue32421] Keeping an exception in cache can segfault the interpreter

2017-12-26 Thread Yonatan Zunger

Yonatan Zunger  added the comment:

3.6.2. But Nick Coghlan pointed out elsewhere that the underlying issue is
more likely to be one of the other objects being pinned in-memory because
of the traceback, so the exception may actually be just an incidental
thing. I'm going to have to work on a better minimal repro case -- this
particular example had both a subprocess.Popen open at the time and a
message-channel object that holds some os.pipes, so there are all sorts of
fun things that may be causing the trouble.

I'll update the bug when I have a chance to do that and narrow it down a
bit more.

On Tue, Dec 26, 2017 at 3:26 AM, Julien Palard 
wrote:

>
> Julien Palard  added the comment:
>
> Tested with:
>
> @memoize()
> def foo(x):
> raise Exception("From foo")
>
>
> for _ ∈ range(5):
> try:
> foo(42)
> except Exception as err:
> print(err)
>
> using a python 3.5.4, 3.6.4, and master(13a6c09), and was unable to
> reproduce it, which version of Python are you using? How are you
> reproducing it?
>
> --
> nosy: +mdk
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue32421] Keeping an exception in cache can segfault the interpreter

2017-12-26 Thread Julien Palard

Julien Palard  added the comment:

Tested with:

@memoize()
def foo(x):
raise Exception("From foo")


for _ ∈ range(5):
try:
foo(42)
except Exception as err:
print(err)

using a python 3.5.4, 3.6.4, and master(13a6c09), and was unable to reproduce 
it, which version of Python are you using? How are you reproducing it?

--
nosy: +mdk

___
Python tracker 

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



[issue32337] Dict order is now guaranteed, so add tests and doc for it

2017-12-26 Thread INADA Naoki

New submission from INADA Naoki :

FYI, Builtin dict is tested for ordering already:
https://github.com/python/cpython/blob/13a6c098c215921e35004f9d3a9b70f601e56500/Lib/test/test_ordered_dict.py#L646-L662

--
nosy: +inada.naoki

___
Python tracker 

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



[issue32072] Issues with binary plists

2017-12-26 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

For example:

a = []
for i in range(22):
a = [a, a]

b = plistlib.dumps(a, fmt=plistlib.FMT_BINARY)

The result is 130 bytes long on patched plistlib. But plistlib.dumps(b) will 
expand to a structure consuming almost a gigabyte of memory on unpatched 
plistlib. Increasing the level of nesting by one will duplicate memory 
consumption, so it is easy to consume all available memory on any computer.

--

___
Python tracker 

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



[issue32196] Rewrite plistlib with functional style

2017-12-26 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

I have made this PR because functional style looks to me more for this kind of 
tasks. For every serialization or deseralization we have a distinct set of 
functions with common state. The state can be passes between functions as 
attributes of a one-time object or as non-local variables. The latter looks 
syntactically cleaner to me and, as a side effect, is faster.

--

___
Python tracker 

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



[issue32259] Misleading "not iterable" Error Message when generator return a "simple" type, and a tuple is expected

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



[issue32259] Misleading "not iterable" Error Message when generator return a "simple" type, and a tuple is expected

2017-12-26 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:


New changeset 13a6c098c215921e35004f9d3a9b70f601e56500 by Serhiy Storchaka in 
branch 'master':
bpo-32259: Make a TypeError message when unpack non-iterable more specific. 
(#4903)
https://github.com/python/cpython/commit/13a6c098c215921e35004f9d3a9b70f601e56500


--

___
Python tracker 

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



[issue26133] asyncio: ugly error related to signal handlers at exit if the loop is not closed explicitly

2017-12-26 Thread Andrew Svetlov

Andrew Svetlov  added the comment:


New changeset 32518b439b9590cce0ef0639e558dc1ce2e152bb by Andrew Svetlov (Miss 
Islington (bot)) in branch '3.6':
bpo-26133: Fix typos (GH-5010) (#5014)
https://github.com/python/cpython/commit/32518b439b9590cce0ef0639e558dc1ce2e152bb


--

___
Python tracker 

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



[issue32308] Replace empty matches adjacent to a previous non-empty match in re.sub()

2017-12-26 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

Could anybody please make a review of at least the documentation part?

--

___
Python tracker 

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



[issue26133] asyncio: ugly error related to signal handlers at exit if the loop is not closed explicitly

2017-12-26 Thread Andrew Svetlov

Andrew Svetlov  added the comment:


New changeset a8f4e15f3d33084862ddd3a7d58cd00034e94f16 by Andrew Svetlov in 
branch 'master':
bpo-26133: Fix typos (#5010)
https://github.com/python/cpython/commit/a8f4e15f3d33084862ddd3a7d58cd00034e94f16


--

___
Python tracker 

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



[issue26133] asyncio: ugly error related to signal handlers at exit if the loop is not closed explicitly

2017-12-26 Thread Roundup Robot

Change by Roundup Robot :


--
pull_requests: +4904

___
Python tracker 

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