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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
63abe9c5
Commit
63abe9c5
authored
Apr 16, 2010
by
Lisandro Dalcin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
define PyBytes_XXX for Py<2.6 and use these through the codebase
parent
40c4dbc8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
22 deletions
+28
-22
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+3
-3
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+20
-2
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+1
-1
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+4
-16
No files found.
Cython/Compiler/ExprNodes.py
View file @
63abe9c5
...
@@ -2262,14 +2262,14 @@ class SliceIndexNode(ExprNode):
...
@@ -2262,14 +2262,14 @@ class SliceIndexNode(ExprNode):
if
self
.
base
.
type
.
is_string
:
if
self
.
base
.
type
.
is_string
:
if
self
.
stop
is
None
:
if
self
.
stop
is
None
:
code
.
putln
(
code
.
putln
(
"%s =
__Pyx_
PyBytes_FromString(%s + %s); %s"
%
(
"%s = PyBytes_FromString(%s + %s); %s"
%
(
self
.
result
(),
self
.
result
(),
self
.
base
.
result
(),
self
.
base
.
result
(),
self
.
start_code
(),
self
.
start_code
(),
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
else
:
else
:
code
.
putln
(
code
.
putln
(
"%s =
__Pyx_
PyBytes_FromStringAndSize(%s + %s, %s - %s); %s"
%
(
"%s = PyBytes_FromStringAndSize(%s + %s, %s - %s); %s"
%
(
self
.
result
(),
self
.
result
(),
self
.
base
.
result
(),
self
.
base
.
result
(),
self
.
start_code
(),
self
.
start_code
(),
...
@@ -6107,7 +6107,7 @@ class CoerceToBooleanNode(CoercionNode):
...
@@ -6107,7 +6107,7 @@ class CoerceToBooleanNode(CoercionNode):
_special_builtins
=
{
_special_builtins
=
{
Builtin
.
list_type
:
'PyList_GET_SIZE'
,
Builtin
.
list_type
:
'PyList_GET_SIZE'
,
Builtin
.
tuple_type
:
'PyTuple_GET_SIZE'
,
Builtin
.
tuple_type
:
'PyTuple_GET_SIZE'
,
Builtin
.
bytes_type
:
'
__Pyx_
PyBytes_GET_SIZE'
,
Builtin
.
bytes_type
:
'PyBytes_GET_SIZE'
,
Builtin
.
unicode_type
:
'PyUnicode_GET_SIZE'
,
Builtin
.
unicode_type
:
'PyUnicode_GET_SIZE'
,
}
}
...
...
Cython/Compiler/ModuleNode.py
View file @
63abe9c5
...
@@ -522,11 +522,29 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -522,11 +522,29 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
#if PY_MAJOR_VERSION >= 3
#if PY_MAJOR_VERSION >= 3
#define PyBaseString_Type PyUnicode_Type
#define PyBaseString_Type PyUnicode_Type
#define PyStringObject PyUnicodeObject
#define PyString_Type PyUnicode_Type
#define PyString_Type PyUnicode_Type
#define PyString_Check PyUnicode_Check
#define PyString_CheckExact PyUnicode_CheckExact
#define PyString_CheckExact PyUnicode_CheckExact
#else
#endif
#if PY_VERSION_HEX < 0x02060000
#define PyBytesObject PyStringObject
#define PyBytes_Type PyString_Type
#define PyBytes_Type PyString_Type
#define PyBytes_Check PyString_Check
#define PyBytes_CheckExact PyString_CheckExact
#define PyBytes_CheckExact PyString_CheckExact
#define PyBytes_FromString PyString_FromString
#define PyBytes_FromStringAndSize PyString_FromStringAndSize
#define PyBytes_FromFormat PyString_FromFormat
#define PyBytes_DecodeEscape PyString_DecodeEscape
#define PyBytes_AsString PyString_AsString
#define PyBytes_AsStringAndSize PyString_AsStringAndSize
#define PyBytes_Size PyString_Size
#define PyBytes_AS_STRING PyString_AS_STRING
#define PyBytes_GET_SIZE PyString_GET_SIZE
#define PyBytes_Repr PyString_Repr
#define PyBytes_Concat PyString_Concat
#define PyBytes_ConcatAndDel PyString_ConcatAndDel
#endif
#endif
#if PY_MAJOR_VERSION >= 3
#if PY_MAJOR_VERSION >= 3
...
@@ -1663,7 +1681,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -1663,7 +1681,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
self
.
generate_filename_init_call
(
code
)
self
.
generate_filename_init_call
(
code
)
code
.
putln
(
"%s = PyTuple_New(0); %s"
%
(
Naming
.
empty_tuple
,
code
.
error_goto_if_null
(
Naming
.
empty_tuple
,
self
.
pos
)));
code
.
putln
(
"%s = PyTuple_New(0); %s"
%
(
Naming
.
empty_tuple
,
code
.
error_goto_if_null
(
Naming
.
empty_tuple
,
self
.
pos
)));
code
.
putln
(
"%s =
__Pyx_
PyBytes_FromStringAndSize(
\
"
\
"
, 0); %s"
%
(
Naming
.
empty_bytes
,
code
.
error_goto_if_null
(
Naming
.
empty_bytes
,
self
.
pos
)));
code
.
putln
(
"%s = PyBytes_FromStringAndSize(
\
"
\
"
, 0); %s"
%
(
Naming
.
empty_bytes
,
code
.
error_goto_if_null
(
Naming
.
empty_bytes
,
self
.
pos
)));
code
.
putln
(
"/*--- Library function declarations ---*/"
)
code
.
putln
(
"/*--- Library function declarations ---*/"
)
env
.
generate_library_function_declarations
(
code
)
env
.
generate_library_function_declarations
(
code
)
...
...
Cython/Compiler/Optimize.py
View file @
63abe9c5
...
@@ -1359,7 +1359,7 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform):
...
@@ -1359,7 +1359,7 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform):
_map_to_capi_len_function
=
{
_map_to_capi_len_function
=
{
Builtin
.
unicode_type
:
"PyUnicode_GET_SIZE"
,
Builtin
.
unicode_type
:
"PyUnicode_GET_SIZE"
,
Builtin
.
str_type
:
"Py_SIZE"
,
# works in Py2 and Py3
Builtin
.
str_type
:
"Py_SIZE"
,
# works in Py2 and Py3
Builtin
.
bytes_type
:
"
__Pyx_
PyBytes_GET_SIZE"
,
Builtin
.
bytes_type
:
"PyBytes_GET_SIZE"
,
Builtin
.
list_type
:
"PyList_GET_SIZE"
,
Builtin
.
list_type
:
"PyList_GET_SIZE"
,
Builtin
.
tuple_type
:
"PyTuple_GET_SIZE"
,
Builtin
.
tuple_type
:
"PyTuple_GET_SIZE"
,
Builtin
.
dict_type
:
"PyDict_Size"
,
Builtin
.
dict_type
:
"PyDict_Size"
,
...
...
Cython/Compiler/PyrexTypes.py
View file @
63abe9c5
...
@@ -1989,8 +1989,8 @@ class CStringType(object):
...
@@ -1989,8 +1989,8 @@ class CStringType(object):
is_string
=
1
is_string
=
1
is_unicode
=
0
is_unicode
=
0
to_py_function
=
"
__Pyx_
PyBytes_FromString"
to_py_function
=
"PyBytes_FromString"
from_py_function
=
"
__Pyx_
PyBytes_AsString"
from_py_function
=
"PyBytes_AsString"
exception_value
=
"NULL"
exception_value
=
"NULL"
def
literal_code
(
self
,
value
):
def
literal_code
(
self
,
value
):
...
@@ -2455,20 +2455,8 @@ def typecast(to_type, from_type, expr_code):
...
@@ -2455,20 +2455,8 @@ def typecast(to_type, from_type, expr_code):
type_conversion_predeclarations
=
"""
type_conversion_predeclarations
=
"""
/* Type Conversion Predeclarations */
/* Type Conversion Predeclarations */
#if PY_MAJOR_VERSION < 3
#define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s)
#define __Pyx_PyBytes_FromString PyString_FromString
#define __Pyx_PyBytes_AsUString(s) ((unsigned char*) PyBytes_AsString(s))
#define __Pyx_PyBytes_FromStringAndSize PyString_FromStringAndSize
#define __Pyx_PyBytes_AsString PyString_AsString
#define __Pyx_PyBytes_GET_SIZE PyString_GET_SIZE
#else
#define __Pyx_PyBytes_FromString PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
#define __Pyx_PyBytes_AsString PyBytes_AsString
#define __Pyx_PyBytes_GET_SIZE PyBytes_GET_SIZE
#endif
#define __Pyx_PyBytes_FromUString(s) __Pyx_PyBytes_FromString((char*)s)
#define __Pyx_PyBytes_AsUString(s) ((unsigned char*) __Pyx_PyBytes_AsString(s))
#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 CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
...
...
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