[issue31272] typing module conflicts with __slots__-classes

2017-08-28 Thread Ilia Korvigo

Ilia Korvigo added the comment:

Indeed, this issue has been fixed. Anyway, it is not mentioned in any release 
notes. Perhaps, this should be mentioned somewhere. 

> On 25 Aug 2017, at 21:43, Ivan Levkivskyi <rep...@bugs.python.org> wrote:
> 
> 
> Ivan Levkivskyi added the comment:
> 
> I think this is fixed in latest version. I thought it was also backported to 
> Python 3.5.3. What is the version you are using? Could you please try 
> updating to the latest bugfix release? (currently these are 3.5.4 and 3.6.2).
> 
> --
> nosy: +levkivskyi
> 
> ___
> Python tracker <rep...@bugs.python.org>
> <http://bugs.python.org/issue31272>
> ___

--

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue31272>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31272] typing module conflicts with __slots__-classes

2017-08-24 Thread Ilia Korvigo

New submission from Ilia Korvigo:

I've got conflicts between Python's typing system and `__slots__`. Here is a 
small reproducible example.

from typing import TypeVar, Generic, Sequence

T = TypeVar("T")

class TestGeneric(Sequence, Generic[T]):
__slots__ = ("test",)

def __init__(self, test: T):
self.test = [test]

def __iter__(self):
return iter(self.test)
def __len__(self):
return len(self.test)

def __contains__(self, item):
return item in self.test

def __getitem__(self, _):
return self.test[0]

Now whenever I try to specify a content type, e.g.

V = TestGeneric[int]

I get 

ValueError: 'test' in __slots__ conflicts with class variable

I use `Generics`  in classes without slots a lot, hence I think this error has 
to be linked to `__slots__`. Moreover, the same class works fine, if you remove 
the `__slots__`

--
components: Library (Lib)
messages: 300797
nosy: grayfall
priority: normal
severity: normal
status: open
title: typing module conflicts with  __slots__-classes
type: behavior
versions: Python 3.5

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue31272>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com