diff options
author | Yobmod <yobmod@gmail.com> | 2021-08-02 17:15:06 +0100 |
---|---|---|
committer | Yobmod <yobmod@gmail.com> | 2021-08-02 17:15:06 +0100 |
commit | e2f8367b53b14acb8e1a86f33334f92a5a306878 (patch) | |
tree | 08d79c6e2c556eb25744292b7cec43aeb79973c2 /git/objects/util.py | |
parent | 024b69669811dc3aa5a018eb3df5535202edf5f9 (diff) | |
download | gitpython-e2f8367b53b14acb8e1a86f33334f92a5a306878.tar.gz |
Fix parse_date typing 5
Diffstat (limited to 'git/objects/util.py')
-rw-r--r-- | git/objects/util.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/git/objects/util.py b/git/objects/util.py index 1ca6f050..d3d8d38b 100644 --- a/git/objects/util.py +++ b/git/objects/util.py @@ -187,9 +187,10 @@ def parse_date(string_date: Union[str, datetime]) -> Tuple[int, int]: offset = -int(utcoffset.total_seconds()) return int(string_date.astimezone(utc).timestamp()), offset else: - raise ValueError(f"Unsupported date format or type: {string_date}" % string_date) + raise ValueError(f"string_date datetime object without tzinfo, {string_date}") - else: + # git time + try: if string_date.count(' ') == 1 and string_date.rfind(':') == -1: timestamp, offset_str = string_date.split() if timestamp.startswith('@'): @@ -243,9 +244,13 @@ def parse_date(string_date: Union[str, datetime]) -> Tuple[int, int]: continue # END exception handling # END for each fmt + # still here ? fail raise ValueError("no format matched") # END handle format + except Exception as e: + raise ValueError(f"Unsupported date format or type: {string_date}" % string_date) from e + # END handle exceptions # precompiled regex |