Patchwork [2,of,4] py3: use unicode literals in changelog.py

login
register
mail settings
Submitter Pulkit Goyal
Date Aug. 3, 2016, 7:18 p.m.
Message ID <d05240139e452340f279.1470251903@pulkit-goyal>
Download mbox | patch
Permalink /patch/16067/
State Accepted
Headers show

Comments

Pulkit Goyal - Aug. 3, 2016, 7:18 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1470249939 -19800
#      Thu Aug 04 00:15:39 2016 +0530
# Branch stable
# Node ID d05240139e452340f279f24887ce6721c0f38978
# Parent  498534103bb67c47f334d84f20ced9bd5acde1aa
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.

Patch

diff -r 498534103bb6 -r d05240139e45 mercurial/changelog.py
--- a/mercurial/changelog.py	Thu Aug 04 00:04:48 2016 +0530
+++ b/mercurial/changelog.py	Thu Aug 04 00:15:39 2016 +0530
@@ -138,9 +138,10 @@ 
         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 +152,8 @@ 
     """
 
     __slots__ = (
-        '_offsets',
-        '_text',
+        u'_offsets',
+        u'_text',
     )
 
     def __new__(cls, text):