Skip to content

A paragraph in ctypes documentation refers to an example that is no longer present in the documentation #115091

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

Closed
ztane opened this issue Feb 6, 2024 · 1 comment
Labels
docs Documentation in the Doc dir

Comments

@ztane
Copy link
Contributor

ztane commented Feb 6, 2024

Documentation

In ctypes documentation for 3.11 there was this excerpt in ctypes documentation:

ctypes can access values like this with the in_dll() class methods of the type. pythonapi is a predefined symbol giving access to the Python C api:

>>> opt_flag = c_int.in_dll(pythonapi, "Py_OptimizeFlag")
>>> print(opt_flag)
c_long(0)
>>>

If the interpreter would have been started with -O, the sample would have printed c_long(1), or c_long(2) if -OO would have been specified.

The example was rewritten for 3.12 to use the - probably more widely understood Py_Version instead:

ctypes can access values like this with the in_dll() class methods of the type. pythonapi is a predefined symbol giving access to the Python C api:

>>> version = ctypes.c_int.in_dll(ctypes.pythonapi, "Py_Version")
>>> print(hex(version.value))
0x30c00a0

However the last paragraph referring to the old example is still present:

If the interpreter would have been started with -O, the sample would have printed c_long(1), or c_long(2) if -OO would have been specified.

Linked PRs

@ztane ztane added the docs Documentation in the Doc dir label Feb 6, 2024
encukou pushed a commit that referenced this issue Feb 26, 2024
… from ctypes documentation (GH-115092)

Remove a left-over sentence that refers to Py_OptimizeFlag 

Remove a left-over sentence that refers to an example that was present in Python 3.10 and was using ``Py_OptimizeFlag``.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Feb 26, 2024
…zeFlag from ctypes documentation (pythonGH-115092)

Remove a left-over sentence that refers to Py_OptimizeFlag

Remove a left-over sentence that refers to an example that was present in Python 3.10 and was using ``Py_OptimizeFlag``.
(cherry picked from commit 915d7dd)

Co-authored-by: Antti Haapala <[email protected]>
encukou pushed a commit that referenced this issue Feb 26, 2024
…izeFlag from ctypes documentation (GH-115092) (GH-115936)

Remove a left-over sentence that refers to an example that was present in Python 3.10 and was using ``Py_OptimizeFlag``.
(cherry picked from commit 915d7dd)

Co-authored-by: Antti Haapala <[email protected]>
@encukou
Copy link
Member

encukou commented Feb 26, 2024

Thanks for the catch!

@encukou encukou closed this as completed Feb 26, 2024
woodruffw pushed a commit to woodruffw-forks/cpython that referenced this issue Mar 4, 2024
…zeFlag from ctypes documentation (pythonGH-115092)

Remove a left-over sentence that refers to Py_OptimizeFlag 

Remove a left-over sentence that refers to an example that was present in Python 3.10 and was using ``Py_OptimizeFlag``.
adorilson pushed a commit to adorilson/cpython that referenced this issue Mar 25, 2024
…zeFlag from ctypes documentation (pythonGH-115092)

Remove a left-over sentence that refers to Py_OptimizeFlag 

Remove a left-over sentence that refers to an example that was present in Python 3.10 and was using ``Py_OptimizeFlag``.
diegorusso pushed a commit to diegorusso/cpython that referenced this issue Apr 17, 2024
…zeFlag from ctypes documentation (pythonGH-115092)

Remove a left-over sentence that refers to Py_OptimizeFlag 

Remove a left-over sentence that refers to an example that was present in Python 3.10 and was using ``Py_OptimizeFlag``.
LukasWoodtli pushed a commit to LukasWoodtli/cpython that referenced this issue Jan 22, 2025
…zeFlag from ctypes documentation (pythonGH-115092)

Remove a left-over sentence that refers to Py_OptimizeFlag 

Remove a left-over sentence that refers to an example that was present in Python 3.10 and was using ``Py_OptimizeFlag``.
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
Projects
None yet
Development

No branches or pull requests

2 participants