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
7023413e
Commit
7023413e
authored
Oct 22, 2009
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Plain Diff
another merge
parents
68e8ed4b
6fe1da39
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
7 deletions
+34
-7
Cython/Compiler/Builtin.py
Cython/Compiler/Builtin.py
+18
-7
tests/run/intern_T431.pyx
tests/run/intern_T431.pyx
+16
-0
No files found.
Cython/Compiler/Builtin.py
View file @
7023413e
...
...
@@ -28,7 +28,7 @@ builtin_function_table = [
#('hex', "", "", ""),
#('id', "", "", ""),
#('input', "", "", ""),
#('intern', "s", "O", "__Pyx_InternFromString"), # Doesn't work for Python str objects with null characters.
(
'intern'
,
"O"
,
"O"
,
"__Pyx_Intern"
),
(
'isinstance'
,
"OO"
,
"b"
,
"PyObject_IsInstance"
),
(
'issubclass'
,
"OO"
,
"b"
,
"PyObject_IsSubclass"
),
(
'iter'
,
"O"
,
"O"
,
"PyObject_GetIter"
),
...
...
@@ -237,12 +237,23 @@ bad:
intern_utility_code
=
UtilityCode
(
proto
=
"""
#if PY_MAJOR_VERSION >= 3
# define __Pyx_InternFromString(s) PyUnicode_InternFromString(s)
#else
# define __Pyx_InternFromString(s) PyString_InternFromString(s)
#endif
"""
)
static PyObject* __Pyx_Intern(PyObject* s); /* proto */
"""
,
impl
=
'''
static PyObject* __Pyx_Intern(PyObject* s) {
if (!(likely(PyString_CheckExact(s)))) {
PyErr_Format(PyExc_TypeError, "Expected str, got %s", Py_TYPE(s)->tp_name);
return 0;
}
Py_INCREF(s);
#if PY_MAJOR_VERSION >= 3
PyUnicode_InternInPlace(&s);
#else
PyString_InternInPlace(&s);
#endif
return s;
}
'''
)
def
put_py23_set_init_utility_code
(
code
,
pos
):
code
.
putln
(
"#if PY_VERSION_HEX < 0x02040000"
)
...
...
tests/run/intern_T431.pyx
0 → 100644
View file @
7023413e
__doc__
=
u"""
>>> s == s_interned
True
>>> intern(s) is s_interned
True
>>> intern('abc') is s_interned
True
>>> intern('abc') is s_interned_dynamic
True
"""
s
=
'abc'
s_interned
=
intern
(
s
)
s_interned_dynamic
=
intern
(
'a'
+
'b'
+
'c'
)
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