Skip to content

Refactor shelllink.py for ITEMIDLIST structure and enhance IShellLink tests.#926

Merged
junkmd merged 5 commits intoenthought:mainfrom
junkmd:stop_faking_in_shelllink
Feb 13, 2026
Merged

Refactor shelllink.py for ITEMIDLIST structure and enhance IShellLink tests.#926
junkmd merged 5 commits intoenthought:mainfrom
junkmd:stop_faking_in_shelllink

Conversation

@junkmd
Copy link
Collaborator

@junkmd junkmd commented Feb 13, 2026

Closes #924

Overview

This pull request changes shelllink.py to correctly define ITEMIDLIST and SHITEMID as ctypes.Structure objects, matching the rules of the Windows API.
It also adds thorough tests for IShellLink::SetIDList and GetIDList, including reliable comparisons using ILIsEqual and careful checks of memory use.
These changes make the COM type definitions more accurate and ensure that shell link operations work dependably.

…link.py`.

- Replace the placeholder `ITEMIDLIST = c_int` with actual `Structure`
  definitions to match Windows API specifications.
- Include `SHITEMID` with `cb` and `abID` fields.
- Add `test_set_and_get_idlist` to `Test_IShellLinkA` and `Test_IShellLinkW`
  in `test_shelllink.py`.
- Verify setting and retrieving a manually constructed `ITEMIDLIST`.
- Use `_CoTaskMemFree` to release the pointer returned by `GetIDList`.
…ist`.

- Use `_Pointer[ITEMIDLIST]` for `ITEMIDLIST` pointers in `IShellLinkA` and
  `IShellLinkW`.
- Specify `hints.Hresult` as the return type for `SetIDList`.
- Import `_Pointer` from `ctypes` within the `TYPE_CHECKING` block.
…elllink.py`.

- Add assertions using `ILIsEqual` in `Test_IShellLinkA` and `Test_IShellLinkW`
  to ensure correct `ITEMIDLIST` handling.
…in `test_shelllink.py`.

- Assert that input `PIDL`s are not COM-allocated and output `PIDL`s are,
  ensuring proper `CoTaskMemFree` usage.
@junkmd junkmd added this to the 1.4.16 milestone Feb 13, 2026
@junkmd junkmd added enhancement New feature or request tests enhance or fix tests typing related to Python static typing system debt labels Feb 13, 2026
@codecov
Copy link

codecov bot commented Feb 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.43%. Comparing base (844a111) to head (fa8a555).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #926      +/-   ##
==========================================
+ Coverage   88.39%   88.43%   +0.03%     
==========================================
  Files         139      139              
  Lines       13502    13546      +44     
==========================================
+ Hits        11935    11979      +44     
  Misses       1567     1567              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@junkmd junkmd merged commit 4eb1b9d into enthought:main Feb 13, 2026
79 of 101 checks passed
@junkmd junkmd deleted the stop_faking_in_shelllink branch February 13, 2026 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

debt enhancement New feature or request tests enhance or fix tests typing related to Python static typing system

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposal: Refactor ITEMIDLIST to a formal Structure and improve IShellLink type safety

1 participant