Skip to content
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

incr/decr behavior is different from documentation #431

Closed
elbaro opened this issue Jan 7, 2025 · 0 comments
Closed

incr/decr behavior is different from documentation #431

elbaro opened this issue Jan 7, 2025 · 0 comments

Comments

@elbaro
Copy link

elbaro commented Jan 7, 2025

    async def _incr_decr(
        self, conn: Connection, command: bytes, key: bytes, delta: int
    ) -> Optional[int]:
        cmd = b"%b %b %a\r\n" % (command, key, delta)
        resp = await self._execute_simple_command(conn, cmd)
        if not resp.isdigit() or resp == const.NOT_FOUND:
            raise ClientException(
                'Memcached {} command failed'.format(str(command)), resp)
        return int(resp) if resp.isdigit() else None

This line return int(resp) if resp.isdigit() else None never returns None because an exception is raised first if it's not digits.

Also from the docstring of incr/decr, resp == const.NOT_FOUND should return None but here it raises ClientException.

"""
        :return: ``int``, new value of the item's data,
        after the increment or ``None`` to indicate the item with
        this value was not found
"""
@elbaro elbaro mentioned this issue Jan 7, 2025
3 tasks
@elbaro elbaro closed this as completed Jan 16, 2025
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

No branches or pull requests

1 participant