Hi,
On Sat, Dec 23, 2023 at 05:09:48PM +0100, Gioele Barabucci wrote:
> Control: tags -1 patch
> 
> Hi Guido,
> 
> On 23/12/23 16:57, Guido Günther wrote:
> > > the gbp-import-dsc script crashes while parsing changelogs that include 
> > > leap
> > > seconds.
> > > 
> > > dateutil.parser._parser.ParserError: second must be in 0..59: Sun,  1 Jan
> > > 2006 00:59:60 +0100
> > 
> > This looks like a bug in dateutil, can you reassign there?
> 
> Not really:
> 
> > > As of 2023-12 there is an open issue asking for support for leap seconds 
> > > in
> > > dateutils [3].

Ah...I missed that one. We should work around it in gbp then.

>  from gbp.git.modifier import GitModifier   # noqa: F401
> @@ -41,7 +42,11 @@ def rfc822_date_to_git(rfc822_date, fuzzy=False):
>      >>> rfc822_date_to_git('So, 26 Feb 1998 8:50:00 +0100', fuzzy=True)
>      '888479400 +0100'
>      """
> +    rfc822_date_orig = rfc822_date
> +    rfc822_date = rfc822_date.replace(":60 ", ":59 ")
>      d = dateutil.parser.parse(rfc822_date, fuzzy=fuzzy)
> +    if rfc822_date != rfc822_date_orig: # Handle leap seconds.
> +        d += datetime.timedelta(seconds=1)

That works. Could you add a line to the doctest in that function too so
we check for and don't break it on accident again. Otherwise I can do it
when applying the patch.

Cheers,
 -- Guido

>      seconds = calendar.timegm(d.utctimetuple())
>      tz = d.strftime("%z")
>      return '%d %s' % (seconds, tz)
> -- 
> 2.43.0
> 

Reply via email to