Skip to content

Fix iscsi enum use for modern cython#143

Merged
rosjat merged 1 commit intopython-scsi:masterfrom
bmeagherix:fix_iscsi_use_for_modern_cython
Nov 10, 2025
Merged

Fix iscsi enum use for modern cython#143
rosjat merged 1 commit intopython-scsi:masterfrom
bmeagherix:fix_iscsi_use_for_modern_cython

Conversation

@bmeagherix
Copy link
Contributor

Similar change as an inflight PR for cython-iscsi

Modern cython changes how cpdef enums are exposed. Update iscsi_device.py so that it will work with both old and new cython.

Given

    cpdef enum iscsi_session_type:
        ISCSI_SESSION_DISCOVERY
        ISCSI_SESSION_NORMAL

We used to be able to either use iscsi.ISCSI_SESSION_NORMAL or iscsi.iscsi_session_type.ISCSI_SESSION_NORMAL. With modern cython, only the latter works.

From https://cython.readthedocs.io/en/latest/src/userguide/language_basics.html#structs-unions-enums

Up to Cython version 3.0.x, this used to copy all item names into the global module namespace, so that they were available both as attributes of the Python enum type (CheseState above) and as global constants. This was changed in Cython 3.1 to distinguish between anonymous cpdef enums, which only create global Python constants for their items, and named cpdef enums, where the items live only in the namespace of the enum type and do not create global Python constants.

Verified the breakage and fix in a venv on Debian Trixie nightly, and on Bookworm.

The https://pypi.org/project/Cython/ shows

  • 3.1.0 (2025-05-08)

@rosjat
Copy link
Collaborator

rosjat commented May 10, 2025

@bmeagherix as soon as the cython-iscsi stuff is in I will merge this. That said you are more or less the guy doing PR requests these days and you seem to be capable of handling your code ;) so what about an invite to the org so you are not dependent on me or diego ?

@bmeagherix
Copy link
Contributor Author

@bmeagherix as soon as the cython-iscsi stuff is in I will merge this. That said you are more or less the guy doing PR requests these days and you seem to be capable of handling your code ;) so what about an invite to the org so you are not dependent on me or diego ?

Thanks @rosjat. I'd be fine with that. (Though TBH I'd still lean towards PRs to get consensus.)

@rosjat
Copy link
Collaborator

rosjat commented Nov 10, 2025

@bmeagherix i added you to a team so you can work on python-scsi and cython-iscsi, since @Flameeyes seems to be busy and I was busy myself lately this seems to be reasonable. Regarding PR's yes I would still do this and not pushing to upstream directly! A review should come first at all time. But this way we can at least make sure you dont have to wait for something all the time.

@rosjat rosjat added the blocked label Nov 10, 2025
@rosjat rosjat merged commit 8ed0aa1 into python-scsi:master Nov 10, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants