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
f1d9c4af
Commit
f1d9c4af
authored
May 30, 2008
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use PyBytes_*() functions instead of PyString_*() in Py3
parent
88164e5e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
5 deletions
+18
-5
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+8
-3
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+10
-2
No files found.
Cython/Compiler/Nodes.py
View file @
f1d9c4af
...
@@ -4238,7 +4238,11 @@ static void __Pyx_AddTraceback(char *funcname) {
...
@@ -4238,7 +4238,11 @@ static void __Pyx_AddTraceback(char *funcname) {
if (!py_funcname) goto bad;
if (!py_funcname) goto bad;
py_globals = PyModule_GetDict(%(GLOBALS)s);
py_globals = PyModule_GetDict(%(GLOBALS)s);
if (!py_globals) goto bad;
if (!py_globals) goto bad;
#if PY_VERSION_MAJOR < 3
empty_string = PyString_FromStringAndSize("", 0);
empty_string = PyString_FromStringAndSize("", 0);
#else
empty_string = PyBytes_FromStringAndSize("", 0);
#endif
if (!empty_string) goto bad;
if (!empty_string) goto bad;
py_code = PyCode_New(
py_code = PyCode_New(
0, /*int argcount,*/
0, /*int argcount,*/
...
@@ -4351,17 +4355,18 @@ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
...
@@ -4351,17 +4355,18 @@ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
*t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
*t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
} else if (t->intern) {
} else if (t->intern) {
*t->p = PyString_InternFromString(t->s);
*t->p = PyString_InternFromString(t->s);
} else {
*t->p = PyString_FromStringAndSize(t->s, t->n - 1);
}
}
#else /* Python 3+ has unicode identifiers */
#else /* Python 3+ has unicode identifiers */
if (t->is_identifier || (t->is_unicode && t->intern)) {
if (t->is_identifier || (t->is_unicode && t->intern)) {
*t->p = PyUnicode_InternFromString(t->s);
*t->p = PyUnicode_InternFromString(t->s);
} else if (t->is_unicode) {
} else if (t->is_unicode) {
*t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
*t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
} else {
*t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
}
}
#endif
#endif
else {
*t->p = PyString_FromStringAndSize(t->s, t->n - 1);
}
if (!*t->p)
if (!*t->p)
return -1;
return -1;
++t;
++t;
...
...
Cython/Compiler/PyrexTypes.py
View file @
f1d9c4af
...
@@ -929,8 +929,8 @@ class CStringType:
...
@@ -929,8 +929,8 @@ class CStringType:
is_string
=
1
is_string
=
1
is_unicode
=
0
is_unicode
=
0
to_py_function
=
"
PyString
_FromString"
to_py_function
=
"
__Pyx_PyBytes
_FromString"
from_py_function
=
"
PyString
_AsString"
from_py_function
=
"
__Pyx_PyBytes
_AsString"
exception_value
=
"NULL"
exception_value
=
"NULL"
def
literal_code
(
self
,
value
):
def
literal_code
(
self
,
value
):
...
@@ -1172,6 +1172,14 @@ def typecast(to_type, from_type, expr_code):
...
@@ -1172,6 +1172,14 @@ def typecast(to_type, from_type, expr_code):
type_conversion_predeclarations
=
"""
type_conversion_predeclarations
=
"""
/* Type Conversion Predeclarations */
/* Type Conversion Predeclarations */
#if PY_VERSION_MAJOR < 3
#define __Pyx_PyBytes_FromString PyString_FromString
#define __Pyx_PyBytes_AsString PyString_AsString
#else
#define __Pyx_PyBytes_FromString PyBytes_FromString
#define __Pyx_PyBytes_AsString PyBytes_AsString
#endif
#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
static INLINE int __Pyx_PyObject_IsTrue(PyObject* x);
static INLINE int __Pyx_PyObject_IsTrue(PyObject* x);
static INLINE PY_LONG_LONG __pyx_PyInt_AsLongLong(PyObject* x);
static INLINE PY_LONG_LONG __pyx_PyInt_AsLongLong(PyObject* x);
...
...
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