Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/encoding.py @ 30031:0f6d6fdd3c2a
pycompat: provide 'ispy3' constant
We compare version_info at several places, which seems enough to define
a constant.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Wed, 28 Sep 2016 20:01:23 +0900 |
parents | 3c6e94d0811c |
children | 02dbfaa6df0b |
comparison
equal
deleted
inserted
replaced
30030:3741a8f86e88 | 30031:0f6d6fdd3c2a |
---|---|
8 from __future__ import absolute_import | 8 from __future__ import absolute_import |
9 | 9 |
10 import array | 10 import array |
11 import locale | 11 import locale |
12 import os | 12 import os |
13 import sys | |
14 import unicodedata | 13 import unicodedata |
15 | 14 |
16 from . import ( | 15 from . import ( |
17 error, | 16 error, |
17 pycompat, | |
18 ) | 18 ) |
19 | 19 |
20 if sys.version_info[0] >= 3: | 20 if pycompat.ispy3: |
21 unichr = chr | 21 unichr = chr |
22 | 22 |
23 # These unicode characters are ignored by HFS+ (Apple Technote 1150, | 23 # These unicode characters are ignored by HFS+ (Apple Technote 1150, |
24 # "Unicode Subtleties"), so we need to ignore them in some places for | 24 # "Unicode Subtleties"), so we need to ignore them in some places for |
25 # sanity. | 25 # sanity. |
26 _ignore = [unichr(int(x, 16)).encode("utf-8") for x in | 26 _ignore = [unichr(int(x, 16)).encode("utf-8") for x in |
27 "200c 200d 200e 200f 202a 202b 202c 202d 202e " | 27 "200c 200d 200e 200f 202a 202b 202c 202d 202e " |
28 "206a 206b 206c 206d 206e 206f feff".split()] | 28 "206a 206b 206c 206d 206e 206f feff".split()] |
29 # verify the next function will work | 29 # verify the next function will work |
30 if sys.version_info[0] >= 3: | 30 if pycompat.ispy3: |
31 assert set(i[0] for i in _ignore) == set([ord(b'\xe2'), ord(b'\xef')]) | 31 assert set(i[0] for i in _ignore) == set([ord(b'\xe2'), ord(b'\xef')]) |
32 else: | 32 else: |
33 assert set(i[0] for i in _ignore) == set(["\xe2", "\xef"]) | 33 assert set(i[0] for i in _ignore) == set(["\xe2", "\xef"]) |
34 | 34 |
35 def hfsignoreclean(s): | 35 def hfsignoreclean(s): |