GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-105733: Deprecate ctypes SetPointerType() and ARRAY() by vstinner · Pull Request #105734 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Jun 13, 2023 •
edited by github-actions Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • Issue: ctypes: Deprecate SetPointerType() and ARRAY() functions #105733

📚 Documentation preview 📚: https://cpython-previews--105734.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added the awaiting core review label Jun 13, 2023
@bedevere-bot bedevere-bot mentioned this pull request Jun 13, 2023
ctypes: Deprecate SetPointerType() and ARRAY() functions #105733
Closed
@vstinner

vstinner commented Jun 13, 2023

Copy link
Copy Markdown
Member Author

A code search on SetPointerType in PyPI top 5,000 projects (2023-04-13) found 0 matching lines (in 0 projects).

A code search on ctypes.ARRAY regex in PyPI top 5,000 projects (2023-04-13) found 0 matching lines (in 0 projects).

It seems like a very low number of projects will be affected by this change.

cc @hugovk

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
pythongh-105733: Deprecate ctypes SetPointerType() and ARRAY()
0be4ba0
@vstinner
vstinner force-pushed the ctypes_deprecate branch from bc0a349 to 0be4ba0 Compare June 13, 2023 17:43
hugovk
hugovk approved these changes Jun 13, 2023
View reviewed changes
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting core review labels Jun 13, 2023
@vstinner
vstinner enabled auto-merge (squash) June 13, 2023 17:59
@vstinner
vstinner merged commit 2211454 into python:main Jun 13, 2023
@bedevere-bot bedevere-bot removed the awaiting merge label Jun 13, 2023
@vstinner
vstinner deleted the ctypes_deprecate branch June 13, 2023 18:35
@vstinner

vstinner commented Jun 13, 2023

Copy link
Copy Markdown
Member Author

Thanks for the review @hugovk.

hugovk reacted with rocket emoji
All reactions
  • 🚀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

encukou
encukou reviewed Mar 22, 2024
View reviewed changes
Comment thread Lib/ctypes/__init__.py
Comment on lines 316 to 319
def ARRAY(typ, len):
import warnings
warnings._deprecated("ctypes.ARRAY", remove=(3, 15))
return typ * len

@encukou encukou Mar 22, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Do you think there's a high expected maintenance overhead or security risk here?

Per PEP 387:

If the expected maintenance overhead and security risk of the deprecated behavior is small (e.g. an old function is reimplemented in terms of a new, more general one), it can stay indefinitely (or until the situation changes).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@vstinner vstinner Mar 22, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

it's not a big maintenance burden nor a securty issue, why do you ask?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@encukou encukou Mar 26, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I ask to see if there's a special reason for remove=(3, 15), or if it can be relaxed.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@vstinner vstinner Mar 26, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

What do you propose? To postpone the removal to Python 3.16?

On PyPI top 8,000 projects (at 2024-03-16), I found only 2 projects using ctypes.ARRAY. I search for regex ctypes.ARRAY|\<ARRAY\> (and excluded unrelated lines).

  • astroid (3.1.0)
  • pwntools (4.12.0)

It's about two lines:

astroid-3.1.0.tar.gz: astroid-3.1.0/tests/brain/test_ctypes.py: ctypes.ARRAY(3, 2)
pwntools-4.12.0.tar.gz: pwntools-4.12.0/pwnlib/adb/bootloader.py: imgarray = ctypes.ARRAY(img_info, self.num_images)

Before the function was only deprecated with a comment:

# XXX Deprecated
def ARRAY(typ, len):
    return typ * len

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@encukou encukou Mar 26, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I'll propose to follow the part of PEP 387 I quoted above. Alternatively, since this does break known projects, to soft-deprecate instead.

But I plan to propose that in the beta period, right now I'm only gathering info. Thanks for the answer!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@encukou encukou encukou left review comments
@hugovk hugovk hugovk approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@vstinner @encukou @hugovk @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.