summaryrefslogtreecommitdiff
path: root/compat.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2016-09-05 14:27:36 +0200
committerAnthon van der Neut <anthon@mnt.org>2016-09-05 14:27:36 +0200
commit54efef321b8aad0552280153fbc698f88d3d4a9f (patch)
tree654e02c3d6ab3f32d5ab43b7a1f17772de5f3473 /compat.py
parent8b6f344a87ee816be1fdef0c31f350745b6606d6 (diff)
downloadruamel.yaml-54efef321b8aad0552280153fbc698f88d3d4a9f.tar.gz
32 bit unicode not supported on MacOS, fixes issue #560.12.9
reported by (David Tagatac)
Diffstat (limited to 'compat.py')
-rw-r--r--compat.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/compat.py b/compat.py
index 23cd968..3a4af90 100644
--- a/compat.py
+++ b/compat.py
@@ -7,6 +7,7 @@ from __future__ import print_function
import sys
import os
import types
+import sysconfig
try:
from ruamel.ordereddict import ordereddict # type: ignore
@@ -36,6 +37,12 @@ except:
PY2 = sys.version_info[0] == 2
PY3 = sys.version_info[0] == 3
+# 4 if 32 bit unicode supported, 2 e.g. on MacOS (issue 56)
+UNICODE_SIZE = sysconfig.get_config_vars().get(
+ 'SIZEOF_WCHAR_T',
+ sysconfig.get_config_vars().get('Py_UNICODE_SIZE', 4))
+
+
if PY3:
def utf8(s):
return s