Mercurial > hg
view mercurial/util.h @ 30579:fbc3f73dc802
py3: utility functions to convert keys of kwargs to bytes/unicodes
Keys of keyword arguments need to be str(unicodes) on Python 3. We have a lot
of function where we pass keyword arguments. Having utility functions to help
converting keys to unicodes before passing and convert back them to bytes once
passed into the function will be helpful. We now have functions named
pycompat.strkwargs(dic) and pycompat.byteskwargs(dic) to help us.
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Wed, 07 Dec 2016 21:53:03 +0530 |
parents | 9b6ff0f940ed |
children | 7d0c69505a66 |
line wrap: on
line source
/* util.h - utility functions for interfacing with the various python APIs. This software may be used and distributed according to the terms of the GNU General Public License, incorporated herein by reference. */ #ifndef _HG_UTIL_H_ #define _HG_UTIL_H_ #include "compat.h" #if PY_MAJOR_VERSION >= 3 #define IS_PY3K #endif typedef struct { PyObject_HEAD char state; int mode; int size; int mtime; } dirstateTupleObject; extern PyTypeObject dirstateTupleType; #define dirstate_tuple_check(op) (Py_TYPE(op) == &dirstateTupleType) /* This should be kept in sync with normcasespecs in encoding.py. */ enum normcase_spec { NORMCASE_LOWER = -1, NORMCASE_UPPER = 1, NORMCASE_OTHER = 0 }; #define MIN(a, b) (((a)<(b))?(a):(b)) /* VC9 doesn't include bool and lacks stdbool.h based on my searching */ #if defined(_MSC_VER) || __STDC_VERSION__ < 199901L #define true 1 #define false 0 typedef unsigned char bool; #else #include <stdbool.h> #endif #endif /* _HG_UTIL_H_ */