Mercurial > public > mercurial-scm > hg-stable
diff mercurial/pure/charencode.py @ 33782:f5fc54e7e467
encoding: drop circular import by proxying through '<policy>.charencode'
I decided not to split charencode.c to new C extension module because it
would duplicate binary codes unnecessarily.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 31 Jul 2017 23:13:47 +0900 |
parents | |
children | b9101467d88b |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial/pure/charencode.py Mon Jul 31 23:13:47 2017 +0900 @@ -0,0 +1,22 @@ +# charencode.py - miscellaneous character encoding +# +# Copyright 2005-2009 Matt Mackall <mpm@selenic.com> and others +# +# This software may be used and distributed according to the terms of the +# GNU General Public License version 2 or any later version. + +from __future__ import absolute_import + +def asciilower(s): + '''convert a string to lowercase if ASCII + + Raises UnicodeDecodeError if non-ASCII characters are found.''' + s.decode('ascii') + return s.lower() + +def asciiupper(s): + '''convert a string to uppercase if ASCII + + Raises UnicodeDecodeError if non-ASCII characters are found.''' + s.decode('ascii') + return s.upper()