From 0510cac958ee53a63506a67e80a452067d8ce8ff Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Fri, 18 Jul 2008 08:40:20 +0200 Subject: [PATCH] always convert byte-docstrings into unicode strings --- Cython/Compiler/Parsing.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Cython/Compiler/Parsing.py b/Cython/Compiler/Parsing.py index cda156d1..3ed1dea2 100644 --- a/Cython/Compiler/Parsing.py +++ b/Cython/Compiler/Parsing.py @@ -8,7 +8,7 @@ from Scanning import PyrexScanner, FileSourceDescriptor import Nodes import ExprNodes from ModuleNode import ModuleNode -from Errors import error, InternalError +from Errors import error, warning, InternalError from Cython import Utils import Future @@ -2151,9 +2151,14 @@ def p_property_decl(s): def p_doc_string(s): if s.sy == 'BEGIN_STRING': - _, result = p_cat_string_literal(s) + pos = s.position() + kind, result = p_cat_string_literal(s) if s.sy != 'EOF': s.expect_newline("Syntax error in doc string") + if kind != 'u': + # warning(pos, "Python 3 requires docstrings to be unicode strings") + if kind == 'b': + result.encoding = None # force a unicode string return result else: return None -- 2.26.2