[PATCH 4 of 4 py3] config: mark parser regexes as bytes explicitly

Martijn Pieters mj at zopatista.com
Wed Nov 9 11:26:08 EST 2016


On 9 November 2016 at 16:23, Augie Fackler <raf at durin42.com> wrote:

> # HG changeset patch
> # User Augie Fackler <augie at google.com>
> # Date 1476019539 14400
> #      Sun Oct 09 09:25:39 2016 -0400
> # Node ID 6eca307a01fe1331f8a754d532f89e9c488c3923
> # Parent  5f29fffcc722d8993fda4155884c1aae4469d2f3
> config: mark parser regexes as bytes explicitly
>
> r-strings are not transformed into bytes by our source transformer magic.
>

+1 on this whole series.



> diff --git a/mercurial/config.py b/mercurial/config.py
> --- a/mercurial/config.py
> +++ b/mercurial/config.py
> @@ -90,13 +90,13 @@ class config(object):
>              self._source.pop((section, item), None)
>
>      def parse(self, src, data, sections=None, remap=None, include=None):
> -        sectionre = util.re.compile(r'\[([^\[]+)\]')
> -        itemre = util.re.compile(r'([^=\s][^=]*?)\s*=\s*(.*\S|)')
> -        contre = util.re.compile(r'\s+(\S|\S.*\S)\s*$')
> -        emptyre = util.re.compile(r'(;|#|\s*$)')
> -        commentre = util.re.compile(r'(;|#)')
> -        unsetre = util.re.compile(r'%unset\s+(\S+)')
> -        includere = util.re.compile(r'%include\s+(\S|\S.*\S)\s*$')
> +        sectionre = util.re.compile(br'\[([^\[]+)\]')
> +        itemre = util.re.compile(br'([^=\s][^=]*?)\s*=\s*(.*\S|)')
> +        contre = util.re.compile(br'\s+(\S|\S.*\S)\s*$')
> +        emptyre = util.re.compile(br'(;|#|\s*$)')
> +        commentre = util.re.compile(br'(;|#)')
> +        unsetre = util.re.compile(br'%unset\s+(\S+)')
> +        includere = util.re.compile(br'%include\s+(\S|\S.*\S)\s*$')
>          section = ""
>          item = None
>          line = 0
> diff --git a/tests/test-check-py3-commands.t b/tests/test-check-py3-
> commands.t
> --- a/tests/test-check-py3-commands.t
> +++ b/tests/test-check-py3-commands.t
> @@ -9,6 +9,6 @@ The full traceback is hidden to have a s
>    >   $PYTHON3 `which hg` $cmd 2>&1 2>&1 | tail -1
>    > done
>    version
> -  TypeError: cannot use a string pattern on a bytes-like object
> +  NameError: name 'basestring' is not defined
>    debuginstall
> -  TypeError: cannot use a string pattern on a bytes-like object
> +  NameError: name 'basestring' is not defined
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>



-- 
Martijn Pieters
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20161109/b9643954/attachment.html>


More information about the Mercurial-devel mailing list