[issue4442] document immutable type subclassing via __new__

2021-08-23 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
assignee: docs@python -> rhettinger

___
Python tracker 

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



[issue4442] document immutable type subclassing via __new__

2021-08-22 Thread Łukasz Langa

Łukasz Langa  added the comment:

Thanks for the patch, Raymond! ✨  ✨

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 2.7, 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



[issue4442] document immutable type subclassing via __new__

2021-08-22 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset ac87b07a10e0ba2834e8de9cf0ea29a40fd882b1 by Łukasz Langa in 
branch '3.9':
[3.9] bpo-4442:  Document use of __new__ for subclasses of immutable types 
(GH-27866) (GH-27900)
https://github.com/python/cpython/commit/ac87b07a10e0ba2834e8de9cf0ea29a40fd882b1


--

___
Python tracker 

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



[issue4442] document immutable type subclassing via __new__

2021-08-22 Thread miss-islington


miss-islington  added the comment:


New changeset 0627918f0b69a15aa16e4ccbb5d8eaae4f6a2caf by Miss Islington (bot) 
in branch '3.10':
bpo-4442:  Document use of __new__ for subclasses of immutable types (GH-27866)
https://github.com/python/cpython/commit/0627918f0b69a15aa16e4ccbb5d8eaae4f6a2caf


--

___
Python tracker 

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



[issue4442] document immutable type subclassing via __new__

2021-08-22 Thread Łukasz Langa

Change by Łukasz Langa :


--
pull_requests: +26355
pull_request: https://github.com/python/cpython/pull/27900

___
Python tracker 

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



[issue4442] document immutable type subclassing via __new__

2021-08-22 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset eec340ea3af27887fcaac4029ebdee99f3713bff by Raymond Hettinger in 
branch 'main':
bpo-4442:  Document use of __new__ for subclasses of immutable types (GH-27866)
https://github.com/python/cpython/commit/eec340ea3af27887fcaac4029ebdee99f3713bff


--
nosy: +lukasz.langa

___
Python tracker 

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



[issue4442] document immutable type subclassing via __new__

2021-08-22 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 9.0 -> 10.0
pull_requests: +26354
pull_request: https://github.com/python/cpython/pull/27899

___
Python tracker 

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



[issue4442] document immutable type subclassing via __new__

2021-08-20 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
keywords: +patch
nosy: +rhettinger
nosy_count: 8.0 -> 9.0
pull_requests: +26321
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/27866

___
Python tracker 

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



[issue4442] document immutable type subclassing via __new__

2021-08-20 Thread Gautam Chaudhuri


Change by Gautam Chaudhuri :


--
nosy: +quantum

___
Python tracker 

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



[issue4442] document immutable type subclassing via __new__

2012-06-13 Thread Mateusz Loskot

Mateusz Loskot mate...@loskot.net added the comment:

Chris Withers' note clarifies it to me, that this should be Python-level rather 
than C-level documentation. Then the note under __new__() in 3. Data model 
seems right.
Simply, I expected to have some notes in C API too

Side note: as mainly Python C API user, I expected to have it documented at C 
API level too.

--

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



[issue4442] document immutable type subclassing via __new__

2012-06-13 Thread Chris Withers

Chris Withers ch...@simplistix.co.uk added the comment:

Probably also wouldn't go amiss to put some notes near the docs for common 
immutable types that people might subclass: datetime, maybe tuple?

--

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



[issue4442] document immutable type subclassing via __new__

2012-06-13 Thread Chris Rebert

Changes by Chris Rebert pyb...@rebertia.com:


--
nosy: +cvrebert

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



[issue4442] document immutable type subclassing via __new__

2012-06-12 Thread Chris Withers

Chris Withers ch...@simplistix.co.uk added the comment:

It's the fact that for immutable types, initialization is done in __new__ 
instead of __init__ that isn't documented anywhere. 

This should be Python-level rather than C-level documentation.

The example I gave in #msg76473 is confusing without docs anywhere that explain 
why this is.

--

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



[issue4442] document immutable type subclassing via __new__

2012-06-12 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

Actually, it is documented: 
http://docs.python.org/dev/reference/datamodel.html#basic-customization

__new__() is intended mainly to allow subclasses of immutable types (like int, 
str, or tuple) to customize instance creation.

It could certainly be better documented, but where?  The tutorial?

--
nosy: +r.david.murray

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



[issue4442] document immutable type subclassing via __new__

2012-06-07 Thread Mateusz Loskot

Changes by Mateusz Loskot mate...@loskot.net:


--
nosy: +mloskot

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



[issue4442] document immutable type subclassing via __new__

2012-06-07 Thread Mateusz Loskot

Mateusz Loskot mate...@loskot.net added the comment:

Is this report about documenting of the concept of immutable types in Python in 
general or regarding existing built-in types, like datetime.datetime?

Generally, the concept of immutable type with relation to tp_new is mentioned 
(sneaked) here:

1) http://docs.python.org/release/3.2.2/c-api/typeobj.html

A good rule of thumb is that for immutable types, all initialization should 
take place in tp_new, while for mutable types, most initialization should be 
deferred to tp_init.

2) http://www.python.org/dev/peps/pep-0253/

Note that for immutable object types, the initialization
cannot be done by the tp_init() slot: this would provide the Python 
user with a way to change the initialization.  Therefore, immutable
objects typically have an empty tp_init() implementation and do
all their initialization in their tp_new() slot.

IMHO, it deserves a dedicated section/chapter in the docs.

--

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



[issue4442] document immutable type subclassing via __new__

2011-11-18 Thread Éric Araujo

Changes by Éric Araujo mer...@netwok.org:


--
nosy: +eric.araujo

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



[issue4442] document immutable type subclassing via __new__

2011-11-15 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
stage:  - needs patch
versions: +Python 3.2, Python 3.3 -Python 3.1

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



[issue4442] document immutable type subclassing via __new__

2008-12-05 Thread Georg Brandl

Georg Brandl [EMAIL PROTECTED] added the comment:

It's not documented for any immutable type. This should be fixed.

--
title: datetime not subclassable in the usual way - document immutable type 
subclassing via __new__

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4442
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com