Commit 40ad34a0 authored by Stefan Behnel's avatar Stefan Behnel

Fix buffer format parsing code to allow the digit '9' in numbers.

Closes GH-2845.
parent 46a91040
......@@ -273,7 +273,7 @@ static int __Pyx_BufFmt_ParseNumber(const char** ts) {
return -1;
} else {
count = *t++ - '0';
while (*t >= '0' && *t < '9') {
while (*t >= '0' && *t <= '9') {
count *= 10;
count += *t++ - '0';
}
......
......@@ -37,7 +37,7 @@ if int_align != 4 or sizeof(int) != 4:
cdef class MockBuffer:
cdef Py_ssize_t zero
cdef Py_ssize_t minusone
cdef object format
cdef bytes format
cdef object itemsize
def __init__(self, format, itemsize):
......@@ -117,6 +117,9 @@ ctypedef struct Char3Int:
int c
int d
ctypedef struct LongString:
char[90198] c
cdef struct CharIntCFloat:
char a
int b
......@@ -180,6 +183,16 @@ def char3int(fmt):
cdef object obj = MockBuffer(fmt, sizeof(Char3Int))
cdef object[Char3Int, ndim=1] buf = obj
@testcase
def long_string(fmt):
"""
>>> long_string("90198s")
"""
cdef object obj = MockBuffer(fmt, sizeof(LongString))
cdef object[LongString, ndim=1] buf = obj
@testcase
def unpacked_struct(fmt):
"""
......
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