Skip to content

[2.7] bpo-29165: doc: make extending/newtypes more Python 3 friendly #211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 21, 2017

Conversation

methane
Copy link
Member

@methane methane commented Feb 21, 2017

No description provided.

PyObject_HEAD_INIT(NULL) can't be used here on Python 3.
PyVarObject_HEAD_INIT(NULL, 0) can be used on both of Python 2 and 3.
@methane methane changed the title bpo-29165: doc: make extending/newtypes more Python 3 friendly [2.7] bpo-29165: doc: make extending/newtypes more Python 3 friendly Feb 21, 2017
@methane methane added docs Documentation in the Doc dir type-feature A feature request or enhancement labels Feb 21, 2017

This line is a bit of a wart; what we'd like to write is::

PyObject_HEAD_INIT(&PyType_Type)
PyVarObject_HEAD_INIT(&PyType_Type, 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is worth to explain what 0 means here (it is a historical artifact).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want this pull request only copies from Python 3's doc.

@@ -244,7 +236,7 @@ doesn't do anything. It can't even be subclassed.
Adding data and methods to the Basic example
--------------------------------------------

Let's expend the basic example to add some data and methods. Let's also make
Let's extend the basic example to add some data and methods. Let's also make
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"extend" or "expand"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -965,14 +957,15 @@ Finalization and De-allocation

This function is called when the reference count of the instance of your type is
reduced to zero and the Python interpreter wants to reclaim it. If your type
has memory to free or other clean-up to perform, put it here. The object itself
needs to be freed here as well. Here is an example of this function::
has memory to free or other clean-up to perform, you can put it here. The
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is changed in these lines?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@methane
Copy link
Member Author

methane commented Feb 21, 2017

I checked diff of Doc/include/*.c between 2.7 and master, and backported many style fixes.

I checked $ gcc `python2-config --cflags` shoddy.c -c for noddy.c, noddy2.c, ... shoddy.c,
and there are no warnings.

@methane methane merged commit 9436bbd into python:2.7 Feb 21, 2017
@methane methane deleted the doc-typehead branch February 21, 2017 12:12
@methane
Copy link
Member Author

methane commented Feb 21, 2017

thanks

jaraco pushed a commit that referenced this pull request Dec 2, 2022
jaraco pushed a commit to jaraco/cpython that referenced this pull request Feb 17, 2023
Fixes python#211

Signed-off-by: Filipe Laíns <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir type-feature A feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants