Skip to content

Unconditionally prints to stdout on exceptions #93

@danvk

Description

@danvk

If you try to parse an expression that python-edtf doesn't like, it prints to stdout before throwing an exception. If this is an expected failure and you catch the exception, you're stuck with a noisy console.

>>> import edtf
>>> edtf.parse_edtf("[2011-05-01..2018-06-24]")
trying to Consecutives.__init__(**{'year': '2018', 'month': '06', 'day': '24', 'lower': ['2011', '-', '05', '-', '01'], 'upper': ['2018', '-', '06', '-', '24']})
...

The print statement here should be removed:

@classmethod
def parse_action(cls, toks):
kwargs = toks.asDict()
try:
return cls(**kwargs) # replace the token list with the class
except Exception as e:
print(f"trying to {cls.__name__}.__init__(**{kwargs})")
raise e

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions