Patchwork [09,of,10] py3: use unicode literals in changelog.py

login
register
mail settings
Submitter Pulkit Goyal
Date Aug. 2, 2016, 8:27 p.m.
Message ID <bb24dfbbd410cd78646c.1470169651@pulkit-goyal>
Download mbox | patch
Permalink /patch/16048/
State Changes Requested
Headers show

Comments

Pulkit Goyal - Aug. 2, 2016, 8:27 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1470169051 -19800
#      Wed Aug 03 01:47:31 2016 +0530
# Node ID bb24dfbbd410cd78646c43557c06475f9d252dd5
# Parent  f7cb9b3eeac9c22dc76f6c5976fda488ba992be2
py3: use unicode literals in changelog.py

collections.namedtuple type and field names must be str in Python 3.
Our custom module importer was rewriting them to bytes literals,
making this fail.

In addition, __slots__ values must also be unicode.
Yuya Nishihara - Aug. 3, 2016, 2:26 p.m.
On Wed, 03 Aug 2016 01:57:31 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1470169051 -19800
> #      Wed Aug 03 01:47:31 2016 +0530
> # Node ID bb24dfbbd410cd78646c43557c06475f9d252dd5
> # Parent  f7cb9b3eeac9c22dc76f6c5976fda488ba992be2
> py3: use unicode literals in changelog.py
> 
> collections.namedtuple type and field names must be str in Python 3.
> Our custom module importer was rewriting them to bytes literals,
> making this fail.
> 
> In addition, __slots__ values must also be unicode.
> 
> diff -r f7cb9b3eeac9 -r bb24dfbbd410 mercurial/changelog.py
> --- a/mercurial/changelog.py	Wed Aug 03 01:43:25 2016 +0530
> +++ b/mercurial/changelog.py	Wed Aug 03 01:47:31 2016 +0530
> @@ -138,9 +138,9 @@
>          return appender(opener, name, mode, buf)
>      return _delay
>  
> -_changelogrevision = collections.namedtuple('changelogrevision',
> -                                            ('manifest', 'user', 'date',
> -                                             'files', 'description', 'extra'))
> +_changelogrevision = collections.namedtuple(u'changelogrevision',
> +                                            (u'manifest', u'user', u'date',
> +                                             u'files', u'description', u'extra'))

This and the last patch looked okay, but there's a check-code error.

+  mercurial/changelog.py:143:
+   >                                              u'files', u'description', u'extra'))
+   line too long

Patch

diff -r f7cb9b3eeac9 -r bb24dfbbd410 mercurial/changelog.py
--- a/mercurial/changelog.py	Wed Aug 03 01:43:25 2016 +0530
+++ b/mercurial/changelog.py	Wed Aug 03 01:47:31 2016 +0530
@@ -138,9 +138,9 @@ 
         return appender(opener, name, mode, buf)
     return _delay
 
-_changelogrevision = collections.namedtuple('changelogrevision',
-                                            ('manifest', 'user', 'date',
-                                             'files', 'description', 'extra'))
+_changelogrevision = collections.namedtuple(u'changelogrevision',
+                                            (u'manifest', u'user', u'date',
+                                             u'files', u'description', u'extra'))
 
 class changelogrevision(object):
     """Holds results of a parsed changelog revision.
@@ -151,8 +151,8 @@ 
     """
 
     __slots__ = (
-        '_offsets',
-        '_text',
+        u'_offsets',
+        u'_text',
     )
 
     def __new__(cls, text):