Skip to content

Introduce new type for RESP3 PUSH notifications #208

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

uglide
Copy link
Contributor

@uglide uglide commented May 9, 2025

Allow clients to distinguish between RESP3 arrays and PUSH types by introducing PushNotification type, which subclasses list.

Fix #128

Allow clients to distinguish between RESP3 arrays
and PUSH types by introducing PushNotification
type which subclasses list.

Fix #128
@uglide uglide requested a review from Copilot May 9, 2025 14:55
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request introduces a new PushNotification type to distinguish RESP3 PUSH notifications from regular RESP3 arrays. Key changes include:

  • Adding type definitions and implementations for PushNotification in both C headers and source files.
  • Updating the module initialization to export the new type.
  • Extending tests and type stubs to verify and document the new PushNotification functionality.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/test_reader.py Introduces tests to check if reader.gets() returns an instance of PushNotification.
src/reader.h Declares the PushNotificationObject struct and external PushNotificationType variable.
src/reader.c Implements PushNotificationType initialization and creation with preallocated size.
src/hiredis.c Sets the PushNotificationType base as PyList_Type and adds it to the module exports.
hiredis/hiredis.pyi Defines the PushNotification type in the type stubs.
hiredis/init.py Exports the PushNotification type as part of the module's public API.

PyListObject* op = (PyListObject*)obj;

/* Allocate memory for the list items if size > 0 */
if (size > 0) {
Copy link
Preview

Copilot AI May 9, 2025

Choose a reason for hiding this comment

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

For a zero-element PushNotification (i.e., when size == 0), the ob_item field is not explicitly initialized. Consider initializing ob_item to a valid empty list pointer to ensure proper list behavior.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PUSH type not distinguishable from ARRAY type in RESP3
1 participant