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
Kirill Smelkov
cython
Commits
22891e07
Commit
22891e07
authored
Jul 13, 2021
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '0.29.x'
parents
a46ed3f4
06607884
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
5 deletions
+56
-5
CHANGES.rst
CHANGES.rst
+14
-0
Cython/Includes/libcpp/string.pxd
Cython/Includes/libcpp/string.pxd
+10
-5
tests/run/cpp_stl_string.pyx
tests/run/cpp_stl_string.pyx
+32
-0
No files found.
CHANGES.rst
View file @
22891e07
...
...
@@ -738,11 +738,25 @@ Bugs fixed
C
code
if
the
module
that
imported
from
them
does
not
use
memory
views
.
Patch
by
David
Woods
.
(
Github
issue
:
issue
:`
1415
`)
*
Several
declarations
in
``
libcpp
.
string
``
were
added
and
corrected
.
Patch
by
Janek
Bevendorff
.
(
Github
issue
:
issue
:`
4268
`)
*
Pickling
unbound
Cython
compiled
methods
failed
.
Patch
by
Pierre
Glaser
.
(
Github
issue
:
issue
:`
2972
`)
*
The
tracing
code
was
adapted
to
work
with
CPython
3.10
.
*
The
optimised
``
in
``
operator
failed
on
unicode
strings
in
Py3
.9
and
later
that
were
constructed
from
an
external
``
wchar_t
``
source
.
Also
,
related
C
compiler
warnings
about
deprecated
C
-
API
usage
were
resolved
.
(
Github
issue
:
issue
:`
3925
`)
*
Some
compiler
crashes
were
resolved
.
Patch
by
David
Woods
.
(
Github
issues
:
issue
:`
4214
`,
:
issue
:`
2811
`)
*
An
incorrect
warning
about
'unused'
generator
expressions
was
removed
.
(
GIthub
issue
:
issue
:`
1699
`)
*
The
attributes
``
gen
.
gi_frame
``
and
``
coro
.
cr_frame
``
of
Cython
compiled
generators
and
coroutines
now
return
an
actual
frame
object
for
introspection
,
instead
of
``
None
``.
...
...
Cython/Includes/libcpp/string.pxd
View file @
22891e07
...
...
@@ -7,6 +7,7 @@ cdef extern from "<string>" namespace "std::string" nogil:
cdef
extern
from
"<string>"
namespace
"std"
nogil
:
cdef
cppclass
string
:
cppclass
iterator
:
iterator
()
char
&
operator
*
()
...
...
@@ -15,6 +16,7 @@ cdef extern from "<string>" namespace "std" nogil:
iterator
operator
--
()
bint
operator
==
(
iterator
)
bint
operator
!=
(
iterator
)
cppclass
reverse_iterator
:
char
&
operator
*
()
iterator
operator
++
()
...
...
@@ -27,8 +29,10 @@ cdef extern from "<string>" namespace "std" nogil:
bint
operator
>
(
reverse_iterator
)
bint
operator
<=
(
reverse_iterator
)
bint
operator
>=
(
reverse_iterator
)
cppclass
const_iterator
(
iterator
):
pass
cppclass
const_reverse_iterator
(
reverse_iterator
):
pass
...
...
@@ -62,6 +66,7 @@ cdef extern from "<string>" namespace "std" nogil:
void
reserve
(
size_t
)
except
+
void
clear
()
bint
empty
()
iterator
erase
(
iterator
first
,
iterator
last
)
iterator
erase
(
iterator
p
)
iterator
erase
(
const_iterator
first
,
const_iterator
last
)
...
...
@@ -90,11 +95,11 @@ cdef extern from "<string>" namespace "std" nogil:
void
push_back
(
char
c
)
except
+
void
pop_back
()
string
&
assign
(
const
string
&
s
)
except
+
string
&
assign
(
const
string
&
s
,
size_t
subpos
,
size_t
sublen
)
except
+
string
&
assign
(
const
char
*
s
,
size_t
n
)
except
+
string
&
assign
(
const
char
*
s
)
except
+
string
&
assign
(
size_t
n
,
char
c
)
except
+
string
&
assign
(
const
string
&
s
)
except
+
string
&
assign
(
const
string
&
s
,
size_t
subpos
,
size_t
sublen
)
except
+
string
&
assign
(
const
char
*
s
,
size_t
n
)
except
+
string
&
assign
(
const
char
*
s
)
except
+
string
&
assign
(
size_t
n
,
char
c
)
except
+
string
&
insert
(
size_t
pos
,
const
string
&
s
,
size_t
subpos
,
size_t
sublen
)
except
+
string
&
insert
(
size_t
pos
,
const
string
&
s
)
except
+
...
...
tests/run/cpp_stl_string.pyx
View file @
22891e07
...
...
@@ -406,6 +406,38 @@ def test_stof(char *a):
cdef
string
s
=
string
(
a
)
return
stof
(
s
)
def
test_to_string
(
x
):
"""
>>> print(test_to_string(5))
si=5 sl=5 ss=5 sss=5
>>> print(test_to_string(-5))
si=-5 sl=-5 ss=5 sss=-5
"""
si
=
to_string
(
<
int
>
x
).
decode
(
'ascii'
)
sl
=
to_string
(
<
long
>
x
).
decode
(
'ascii'
)
ss
=
to_string
(
<
size_t
>
abs
(
x
)).
decode
(
'ascii'
)
sss
=
to_string
(
<
ssize_t
>
x
).
decode
(
'ascii'
)
return
f"si=
{
si
}
sl=
{
sl
}
ss=
{
ss
}
sss=
{
sss
}
"
def
test_stoi
(
char
*
a
):
"""
>>> test_stoi(b'5')
5
"""
cdef
string
s
=
string
(
a
)
return
stoi
(
s
)
def
test_stof
(
char
*
a
):
"""
>>> test_stof(b'5.5')
5.5
"""
cdef
string
s
=
string
(
a
)
return
stof
(
s
)
_WARNINGS
=
"""
21:31: Cannot pass Python object as C++ data structure reference (string &), will pass by copy.
"""
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