On Sun, 23 Sep 2018 01:18:52 -0400, Matt Harbison wrote: > # HG changeset patch > # User Matt Harbison <matt_harbi...@yahoo.com> > # Date 1537667864 14400 > # Sat Sep 22 21:57:44 2018 -0400 > # Node ID 10b1e61357ac546e70e590cc79889c0889e7bc22 > # Parent ca417c9464d378661e9e962be1447647006297f3 > encoding: teach unitolocal() and unifromlocal() to handle None > > These are aliased to str{to,from}local(), along with pycompat.identity(), > depending on the platform. It's inconsistent that None works on py2 because > of > identity(), but not on py3. This will be needed in the next patch. > > diff --git a/mercurial/encoding.py b/mercurial/encoding.py > --- a/mercurial/encoding.py > +++ b/mercurial/encoding.py > @@ -202,10 +202,14 @@ def fromlocal(s): > > def unitolocal(u): > """Convert a unicode string to a byte string of local encoding""" > + if u is None: > + return None > return tolocal(u.encode('utf-8')) > > def unifromlocal(s): > """Convert a byte string of local encoding to a unicode string""" > + if s is None: > + return None > return fromlocal(s).decode('utf-8')
I'm not a fan of making low-level functions untyped. Instead, maybe you can wrap function calls with pycompat.rapply(). _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel