-
Notifications
You must be signed in to change notification settings - Fork 177
Construct instance of appropriate class in Event._init #752
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,7 +89,7 @@ cdef class Event: | |
|
||
@classmethod | ||
def _init(cls, device_id: int, ctx_handle: Context, options=None): | ||
cdef Event self = Event.__new__(Event) | ||
cdef Event self = Event.__new__(cls) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add a test for a derived class of Event to ensure that we don't accidentally regress on what this enables? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can go about this in two ways:
Ultimately, (2) calls down to (1) but in a way that's an implementation detail. Any preferences? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets take the easy path and we can always revisit in the future if we see value in doing so. |
||
cdef EventOptions opts = check_or_create_options(EventOptions, options, "Event options") | ||
flags = 0x0 | ||
self._timing_disabled = False | ||
|
Uh oh!
There was an error while loading. Please reload this page.
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.
This ensures that a
cls
instance is produced here, which could be different fromEvent
ifcls
is a subclass.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 think this works! I was trying:
and getting compile time errors.