Skip to content

Can't OR any JournalOpenModes together #72

@panzi

Description

@panzi

The SystemD documentation of sd_journal_open() says:

The second argument is a flags field, which may consist of the following flags ORed together:

See: https://www.freedesktop.org/software/systemd/man/latest/sd_journal_open.html

But the JournalOpenMode._missing_ disallows any ORed value:

@classmethod
def _missing_(cls, value) -> 'JournalOpenMode':
if value == SD_JOURNAL_SYSTEM_ONLY:
warnings.warn(
"The JournalOpenMode.SYSTEM_ONLY is deprecated and the alias of "
"JournalOpenMode.SYSTEM in the systemd library.",
DeprecationWarning,
stacklevel=2
)
return cls.SYSTEM
raise ValueError(f"{value} is not a valid open mode")

SystemD defines SD_JOURNAL_SYSTEM_ONLY to be the same as SD_JOURNAL_SYSTEM anyway, rendering the _missing_() method useless for that case:

https://github.com/systemd/systemd/blob/49eb2d50b4328956b0d8fdf173425e2029b7d5ee/src/systemd/sd-journal.h#L74

Except it breaks ORing! I currently hack-fix this bug in my code with this line:

del JournalOpenMode._missing_

I suggest to just remove that method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions