Fix invalid escape sequence in build-many-glibcs.py

Message ID 843f95f3-2a2-5426-a54b-eb871e2c5b2c@redhat.com
State Committed
Commit 781427354068535f159388776da4f21043e237a8
Headers
Series Fix invalid escape sequence in build-many-glibcs.py |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
redhat-pt-bot/TryBot-32bit success Build for i686
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Testing passed

Commit Message

Joseph Myers Jan. 9, 2024, 9:23 p.m. UTC
  Running build-many-glibcs.py with Python 3.12 or later produces a
warning:

build-many-glibcs.py:173: SyntaxWarning: invalid escape sequence '\.'
  m = re.fullmatch('([0-9]+)\.([0-9]+)[.0-9]*', l)

Use a raw string instead to avoid that warning.  (Note: I haven't
checked whether any other Python scripts included with glibc might
have issues with newer Python versions.)
  

Comments

Florian Weimer Jan. 10, 2024, 10:39 a.m. UTC | #1
* Joseph Myers:

> Running build-many-glibcs.py with Python 3.12 or later produces a
> warning:
>
> build-many-glibcs.py:173: SyntaxWarning: invalid escape sequence '\.'
>   m = re.fullmatch('([0-9]+)\.([0-9]+)[.0-9]*', l)
>
> Use a raw string instead to avoid that warning.  (Note: I haven't
> checked whether any other Python scripts included with glibc might
> have issues with newer Python versions.)
>
> diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
> index 7e0b90be89..9a929a6430 100755
> --- a/scripts/build-many-glibcs.py
> +++ b/scripts/build-many-glibcs.py
> @@ -170,7 +170,7 @@ class Context(object):
>              if l.startswith(starttext):
>                  l = l[len(starttext):]
>                  l = l.rstrip('"\n')
> -                m = re.fullmatch('([0-9]+)\.([0-9]+)[.0-9]*', l)
> +                m = re.fullmatch(r'([0-9]+)\.([0-9]+)[.0-9]*', l)
>                  return '%s.%s' % m.group(1, 2)
>          print('error: could not determine glibc version')
>          exit(1)

Looks good.

Thanks,
Florian
  
H.J. Lu Jan. 10, 2024, 3:18 p.m. UTC | #2
On Tue, Jan 9, 2024 at 1:24 PM Joseph Myers <josmyers@redhat.com> wrote:
>
> Running build-many-glibcs.py with Python 3.12 or later produces a
> warning:
>
> build-many-glibcs.py:173: SyntaxWarning: invalid escape sequence '\.'
>   m = re.fullmatch('([0-9]+)\.([0-9]+)[.0-9]*', l)
>
> Use a raw string instead to avoid that warning.  (Note: I haven't
> checked whether any other Python scripts included with glibc might
> have issues with newer Python versions.)

I also got:

/glibc/scripts/build-many-glibcs.py:
570: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled
for removal in a future version. Use timezone-aware objects to represent datetim
es in UTC: datetime.datetime.now(datetime.UTC).
  build_time = datetime.datetime.utcnow()

Should it also be fixed?

> diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
> index 7e0b90be89..9a929a6430 100755
> --- a/scripts/build-many-glibcs.py
> +++ b/scripts/build-many-glibcs.py
> @@ -170,7 +170,7 @@ class Context(object):
>              if l.startswith(starttext):
>                  l = l[len(starttext):]
>                  l = l.rstrip('"\n')
> -                m = re.fullmatch('([0-9]+)\.([0-9]+)[.0-9]*', l)
> +                m = re.fullmatch(r'([0-9]+)\.([0-9]+)[.0-9]*', l)
>                  return '%s.%s' % m.group(1, 2)
>          print('error: could not determine glibc version')
>          exit(1)
>
> --
> Joseph S. Myers
> josmyers@redhat.com
>
  
H.J. Lu Jan. 10, 2024, 3:23 p.m. UTC | #3
On Wed, Jan 10, 2024 at 7:18 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Tue, Jan 9, 2024 at 1:24 PM Joseph Myers <josmyers@redhat.com> wrote:
> >
> > Running build-many-glibcs.py with Python 3.12 or later produces a
> > warning:
> >
> > build-many-glibcs.py:173: SyntaxWarning: invalid escape sequence '\.'
> >   m = re.fullmatch('([0-9]+)\.([0-9]+)[.0-9]*', l)
> >
> > Use a raw string instead to avoid that warning.  (Note: I haven't
> > checked whether any other Python scripts included with glibc might
> > have issues with newer Python versions.)
>
> I also got:
>
> /glibc/scripts/build-many-glibcs.py:
> 570: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled
> for removal in a future version. Use timezone-aware objects to represent datetim
> es in UTC: datetime.datetime.now(datetime.UTC).
>   build_time = datetime.datetime.utcnow()
>
> Should it also be fixed?

I saw it has been fixed now.

> > diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
> > index 7e0b90be89..9a929a6430 100755
> > --- a/scripts/build-many-glibcs.py
> > +++ b/scripts/build-many-glibcs.py
> > @@ -170,7 +170,7 @@ class Context(object):
> >              if l.startswith(starttext):
> >                  l = l[len(starttext):]
> >                  l = l.rstrip('"\n')
> > -                m = re.fullmatch('([0-9]+)\.([0-9]+)[.0-9]*', l)
> > +                m = re.fullmatch(r'([0-9]+)\.([0-9]+)[.0-9]*', l)
> >                  return '%s.%s' % m.group(1, 2)
> >          print('error: could not determine glibc version')
> >          exit(1)
> >
> > --
> > Joseph S. Myers
> > josmyers@redhat.com
> >
>
>
> --
> H.J.
  

Patch

diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
index 7e0b90be89..9a929a6430 100755
--- a/scripts/build-many-glibcs.py
+++ b/scripts/build-many-glibcs.py
@@ -170,7 +170,7 @@  class Context(object):
             if l.startswith(starttext):
                 l = l[len(starttext):]
                 l = l.rstrip('"\n')
-                m = re.fullmatch('([0-9]+)\.([0-9]+)[.0-9]*', l)
+                m = re.fullmatch(r'([0-9]+)\.([0-9]+)[.0-9]*', l)
                 return '%s.%s' % m.group(1, 2)
         print('error: could not determine glibc version')
         exit(1)