Patchwork [1,of,3] py3: use unicodes in __slots__

login
register
mail settings
Submitter Pulkit Goyal
Date Dec. 4, 2016, 2 p.m.
Message ID <d8439c1b853de322d88b.1480860050@pulkit-goyal>
Download mbox | patch
Permalink /patch/17816/
State Accepted
Headers show

Comments

Pulkit Goyal - Dec. 4, 2016, 2 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1480529330 -19800
#      Wed Nov 30 23:38:50 2016 +0530
# Node ID d8439c1b853de322d88b60ee14ab29b065ae6b5b
# Parent  5b11b0af9dab460d6bca6f28f395c8bb55ee10cd
py3: use unicodes in __slots__

__slots__ in Python 3 accepts only unicodes and there is no harm using
unicodes in __slots__. So just adding u'' is fine. Previous occurences of this
problem are treated the same way.
Yuya Nishihara - Dec. 4, 2016, 2:32 p.m.
On Sun, 04 Dec 2016 19:30:50 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1480529330 -19800
> #      Wed Nov 30 23:38:50 2016 +0530
> # Node ID d8439c1b853de322d88b60ee14ab29b065ae6b5b
> # Parent  5b11b0af9dab460d6bca6f28f395c8bb55ee10cd
> py3: use unicodes in __slots__

These look good. Queued, thanks.

Patch

diff -r 5b11b0af9dab -r d8439c1b853d mercurial/statprof.py
--- a/mercurial/statprof.py	Mon Nov 21 08:09:41 2016 -0800
+++ b/mercurial/statprof.py	Wed Nov 30 23:38:50 2016 +0530
@@ -177,7 +177,7 @@ 
 class CodeSite(object):
     cache = {}
 
-    __slots__ = ('path', 'lineno', 'function', 'source')
+    __slots__ = (u'path', u'lineno', u'function', u'source')
 
     def __init__(self, path, lineno, function):
         self.path = path
@@ -232,7 +232,7 @@ 
         return os.path.basename(self.path)
 
 class Sample(object):
-    __slots__ = ('stack', 'time')
+    __slots__ = (u'stack', u'time')
 
     def __init__(self, stack, time):
         self.stack = stack
diff -r 5b11b0af9dab -r d8439c1b853d tests/test-check-py3-compat.t
--- a/tests/test-check-py3-compat.t	Mon Nov 21 08:09:41 2016 -0800
+++ b/tests/test-check-py3-compat.t	Wed Nov 30 23:38:50 2016 +0530
@@ -36,7 +36,6 @@ 
   mercurial/cffi/mpatch.py: error importing: <ImportError> No module named 'mercurial.cffi' (error at check-py3-compat.py:*)
   mercurial/cffi/osutil.py: error importing: <ImportError> No module named 'mercurial.cffi' (error at check-py3-compat.py:*)
   mercurial/scmwindows.py: error importing: <ImportError> No module named 'msvcrt' (error at win32.py:*)
-  mercurial/statprof.py: error importing: <TypeError> __slots__ items must be strings, not 'bytes' (error at statprof.py:*)
   mercurial/win32.py: error importing: <ImportError> No module named 'msvcrt' (error at win32.py:*)
   mercurial/windows.py: error importing: <ImportError> No module named 'msvcrt' (error at windows.py:*)