Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
ac6b858e
Commit
ac6b858e
authored
May 18, 2018
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent UnicodeEncodeError in Py2 when ``%s`` formatting is optimised for unicode strings.
parent
eb0e4666
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
1 deletion
+18
-1
CHANGES.rst
CHANGES.rst
+3
-0
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+1
-1
Cython/Utility/ModuleSetupCode.c
Cython/Utility/ModuleSetupCode.c
+1
-0
tests/run/fstring.pyx
tests/run/fstring.pyx
+13
-0
No files found.
CHANGES.rst
View file @
ac6b858e
...
...
@@ -13,6 +13,9 @@ Bugs fixed
* Overriding cpdef methods did not work in Python subclasses with slots.
(Github issue #1771)
* ``UnicodeEncodeError`` in Py2 when ``%s`` formatting is optimised for
unicode strings.
0.28.2 (2018-04-13)
===================
...
...
Cython/Compiler/ExprNodes.py
View file @
ac6b858e
...
...
@@ -3164,7 +3164,7 @@ class FormattedValueNode(ExprNode):
c_format_spec
=
None
find_conversion_func
=
{
's'
:
'PyObject_
Str
'
,
's'
:
'PyObject_
Unicode
'
,
'r'
:
'PyObject_Repr'
,
'a'
:
'PyObject_ASCII'
,
# NOTE: mapped to PyObject_Repr() in Py2
}.
get
...
...
Cython/Utility/ModuleSetupCode.c
View file @
ac6b858e
...
...
@@ -558,6 +558,7 @@ static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
#define PyString_Type PyUnicode_Type
#define PyString_Check PyUnicode_Check
#define PyString_CheckExact PyUnicode_CheckExact
#define PyObject_Unicode PyObject_Str
#endif
#if PY_MAJOR_VERSION >= 3
...
...
tests/run/fstring.pyx
View file @
ac6b858e
...
...
@@ -500,3 +500,16 @@ def generated_fstring(int i, unicode u not None, o):
u
,
u
,
u
,
u
,
o
,
o
,
o
,
o
,
)
@
cython
.
test_assert_path_exists
(
"//FormattedValueNode"
,
"//AddNode"
,
)
def
percent_s_unicode
(
u
,
int
i
):
u"""
>>> u = u'x
\
u0194
z'
>>> print(percent_s_unicode(u, 12))
x
\
u0194
z-12
"""
return
u"%s-%d"
%
(
u
,
i
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment