[issue44649] dataclasses slots with init=False field raises AttributeException

2021-11-22 Thread miss-islington


miss-islington  added the comment:


New changeset 10343bd98390ef15909e3a19f26a6178162996fd by Miss Islington (bot) 
in branch '3.10':
bpo-44649: Fix dataclasses(slots=True) with a field with a default, but 
init=False (GH-29692)
https://github.com/python/cpython/commit/10343bd98390ef15909e3a19f26a6178162996fd


--

___
Python tracker 

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



[issue44649] dataclasses slots with init=False field raises AttributeException

2021-11-22 Thread Eric V. Smith


Eric V. Smith  added the comment:

Thanks for the bug report!

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



[issue44649] dataclasses slots with init=False field raises AttributeException

2021-11-22 Thread Eric V. Smith


Eric V. Smith  added the comment:


New changeset d3062f672c92855b7e9e962ad4bf1a67abd4589b by Eric V. Smith in 
branch 'main':
bpo-44649: Fix dataclasses(slots=True) with a field with a default, but 
init=False (GH-29692)
https://github.com/python/cpython/commit/d3062f672c92855b7e9e962ad4bf1a67abd4589b


--

___
Python tracker 

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



[issue44649] dataclasses slots with init=False field raises AttributeException

2021-11-22 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 2.0 -> 3.0
pull_requests: +27940
pull_request: https://github.com/python/cpython/pull/29704

___
Python tracker 

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



[issue44649] dataclasses slots with init=False field raises AttributeException

2021-11-21 Thread Eric V. Smith


Change by Eric V. Smith :


--
versions: +Python 3.11

___
Python tracker 

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



[issue44649] dataclasses slots with init=False field raises AttributeException

2021-11-21 Thread Eric V. Smith


Change by Eric V. Smith :


--
keywords: +patch
pull_requests: +27930
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/29692

___
Python tracker 

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



[issue44649] dataclasses slots with init=False field raises AttributeException

2021-09-04 Thread Christodoulos Tsoulloftas


Christodoulos Tsoulloftas  added the comment:

Thanks for the update eric, yeah the new error messages are much more 
comprehensive and I am glad to hear the original issue will be addressed as 
well.

--

___
Python tracker 

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



[issue44649] dataclasses slots with init=False field raises AttributeException

2021-07-16 Thread Eric V. Smith


Eric V. Smith  added the comment:

With Pablo's changes, the error now reads (in 3.11):

obj.b
^
AttributeError: 'Example' object has no attribute 'b'

Which is a vast improvement!

I'm working on a PR to initialize obj.b in __init__.

--

___
Python tracker 

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



[issue44649] dataclasses slots with init=False field raises AttributeException

2021-07-16 Thread Eric V. Smith


Eric V. Smith  added the comment:

I created issue 44655 for the confusing error message.

The problem with dataclasses is that the instance variable 'b' needs to be 
initialized, instead of the current dataclasses behavior where it relies on the 
class variable when reading 'b'.

--

___
Python tracker 

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



[issue44649] dataclasses slots with init=False field raises AttributeException

2021-07-15 Thread Eric V. Smith


Change by Eric V. Smith :


--
assignee:  -> eric.smith
nosy: +eric.smith

___
Python tracker 

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



[issue44649] dataclasses slots with init=False field raises AttributeException

2021-07-15 Thread Christodoulos Tsoulloftas

New submission from Christodoulos Tsoulloftas :

I am trying the new slots directive but I get an AttributeError when I try to 
access a field with init=False


>>> from dataclasses import dataclass, field
>>> 
>>> @dataclass(slots=True)
... class Example:
... a: str
... b: str = field(default="b", init=False)
... 
>>> obj = Example("a")
>>> obj.__slots__
('a', 'b')
>>> obj.
obj.a  obj.b  
>>> obj.a
'a'
>>> obj.b
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: b. Did you mean: 'b'?
>>> 



❯ python --version
Python 3.10.0b4+

--
components: Library (Lib)
messages: 397575
nosy: tefra
priority: normal
severity: normal
status: open
title: dataclasses slots with init=False field raises AttributeException
type: behavior
versions: Python 3.10

___
Python tracker 

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