Commit 22891e07 authored by Stefan Behnel's avatar Stefan Behnel

Merge branch '0.29.x'

parents a46ed3f4 06607884
......@@ -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``.
......
......@@ -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 +
......
......@@ -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.
"""
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment