Commit 4345d482 authored by Robert Bradshaw's avatar Robert Bradshaw

merge

parents 3d9eb90d 7c482507
...@@ -2338,7 +2338,7 @@ typedef struct { ...@@ -2338,7 +2338,7 @@ typedef struct {
void (*DECREF)(void*, PyObject*, int); void (*DECREF)(void*, PyObject*, int);
void (*GOTREF)(void*, PyObject*, int); void (*GOTREF)(void*, PyObject*, int);
void (*GIVEREF)(void*, PyObject*, int); void (*GIVEREF)(void*, PyObject*, int);
void* (*NewContext)(const char*, int, char*); void* (*NewContext)(const char*, int, const char*);
int (*FinishContext)(void**); int (*FinishContext)(void**);
} __Pyx_RefnannyAPIStruct; } __Pyx_RefnannyAPIStruct;
static __Pyx_RefnannyAPIStruct *__Pyx_Refnanny = NULL; static __Pyx_RefnannyAPIStruct *__Pyx_Refnanny = NULL;
......
...@@ -1688,6 +1688,11 @@ def p_c_simple_base_type(s, self_flag, nonempty): ...@@ -1688,6 +1688,11 @@ def p_c_simple_base_type(s, self_flag, nonempty):
if looking_at_base_type(s): if looking_at_base_type(s):
#print "p_c_simple_base_type: looking_at_base_type at", s.position() #print "p_c_simple_base_type: looking_at_base_type at", s.position()
is_basic = 1 is_basic = 1
if s.sy == 'IDENT' and s.systring in special_basic_c_types:
signed, longness = special_basic_c_types[s.systring]
name = s.systring
s.next()
else:
signed, longness = p_sign_and_longness(s) signed, longness = p_sign_and_longness(s)
if s.sy == 'IDENT' and s.systring in basic_c_type_names: if s.sy == 'IDENT' and s.systring in basic_c_type_names:
name = s.systring name = s.systring
...@@ -1811,12 +1816,18 @@ def looking_at_dotted_name(s): ...@@ -1811,12 +1816,18 @@ def looking_at_dotted_name(s):
else: else:
return 0 return 0
basic_c_type_names = ("void", "char", "int", "float", "double", "Py_ssize_t", "size_t", "bint") basic_c_type_names = ("void", "char", "int", "float", "double", "bint")
special_basic_c_types = {
# name : (signed, longness)
"Py_ssize_t" : (2, 0),
"size_t" : (0, 0),
}
sign_and_longness_words = ("short", "long", "signed", "unsigned") sign_and_longness_words = ("short", "long", "signed", "unsigned")
base_type_start_words = \ base_type_start_words = \
basic_c_type_names + sign_and_longness_words basic_c_type_names + sign_and_longness_words + tuple(special_basic_c_types)
def p_sign_and_longness(s): def p_sign_and_longness(s):
signed = 1 signed = 1
......
...@@ -1283,8 +1283,8 @@ modifiers_and_name_to_type = { ...@@ -1283,8 +1283,8 @@ modifiers_and_name_to_type = {
(2, 1, "int"): c_slong_type, (2, 1, "int"): c_slong_type,
(2, 2, "int"): c_slonglong_type, (2, 2, "int"): c_slonglong_type,
(1, 0, "Py_ssize_t"): c_py_ssize_t_type, (2, 0, "Py_ssize_t"): c_py_ssize_t_type,
(1, 0, "size_t") : c_size_t_type, (0, 0, "size_t") : c_size_t_type,
(1, 0, "long"): c_long_type, (1, 0, "long"): c_long_type,
(1, 0, "short"): c_short_type, (1, 0, "short"): c_short_type,
...@@ -1492,8 +1492,13 @@ static INLINE PY_LONG_LONG __pyx_PyInt_AsLongLong(PyObject* x) { ...@@ -1492,8 +1492,13 @@ static INLINE PY_LONG_LONG __pyx_PyInt_AsLongLong(PyObject* x) {
} }
else { else {
PY_LONG_LONG val; PY_LONG_LONG val;
#if PY_VERSION_HEX < 0x03000000
PyObject* tmp = PyNumber_Int(x); if (!tmp) return (PY_LONG_LONG)-1; PyObject* tmp = PyNumber_Int(x); if (!tmp) return (PY_LONG_LONG)-1;
val = __pyx_PyInt_AsLongLong(tmp); val = __pyx_PyInt_AsLongLong(tmp);
#else
PyObject* tmp = PyNumber_Long(x); if (!tmp) return (PY_LONG_LONG)-1;
val = PyLong_AsLongLong(tmp);
#endif
Py_DECREF(tmp); Py_DECREF(tmp);
return val; return val;
} }
...@@ -1516,8 +1521,13 @@ static INLINE unsigned PY_LONG_LONG __pyx_PyInt_AsUnsignedLongLong(PyObject* x) ...@@ -1516,8 +1521,13 @@ static INLINE unsigned PY_LONG_LONG __pyx_PyInt_AsUnsignedLongLong(PyObject* x)
} }
else { else {
unsigned PY_LONG_LONG val; unsigned PY_LONG_LONG val;
#if PY_VERSION_HEX < 0x03000000
PyObject* tmp = PyNumber_Int(x); if (!tmp) return (PY_LONG_LONG)-1; PyObject* tmp = PyNumber_Int(x); if (!tmp) return (PY_LONG_LONG)-1;
val = __pyx_PyInt_AsUnsignedLongLong(tmp); val = __pyx_PyInt_AsUnsignedLongLong(tmp);
#else
PyObject* tmp = PyNumber_Long(x); if (!tmp) return (PY_LONG_LONG)-1;
val = PyLong_AsUnsignedLongLong(tmp);
#endif
Py_DECREF(tmp); Py_DECREF(tmp);
return val; return val;
} }
......
...@@ -23,9 +23,9 @@ class Context(object): ...@@ -23,9 +23,9 @@ class Context(object):
self.errors = [] self.errors = []
def regref(self, obj, lineno, is_null): def regref(self, obj, lineno, is_null):
log(LOG_ALL, 'regref', "<NULL>" if is_null else obj, lineno) log(LOG_ALL, u'regref', u"<NULL>" if is_null else obj, lineno)
if is_null: if is_null:
self.errors.append("NULL argument on line %d" % lineno) self.errors.append(u"NULL argument on line %d" % lineno)
return return
id_ = id(obj) id_ = id(obj)
count, linenumbers = self.refs.get(id_, (0, [])) count, linenumbers = self.refs.get(id_, (0, []))
...@@ -33,14 +33,14 @@ class Context(object): ...@@ -33,14 +33,14 @@ class Context(object):
linenumbers.append(lineno) linenumbers.append(lineno)
def delref(self, obj, lineno, is_null): def delref(self, obj, lineno, is_null):
log(LOG_ALL, 'delref', "<NULL>" if is_null else obj, lineno) log(LOG_ALL, u'delref', u"<NULL>" if is_null else obj, lineno)
if is_null: if is_null:
self.errors.append("NULL argument on line %d" % lineno) self.errors.append(u"NULL argument on line %d" % lineno)
return return
id_ = id(obj) id_ = id(obj)
count, linenumbers = self.refs.get(id_, (0, [])) count, linenumbers = self.refs.get(id_, (0, []))
if count == 0: if count == 0:
self.errors.append("Too many decrefs on line %d, reference acquired on lines %r" % self.errors.append(u"Too many decrefs on line %d, reference acquired on lines %r" %
(lineno, linenumbers)) (lineno, linenumbers))
elif count == 1: elif count == 1:
del self.refs[id_] del self.refs[id_]
...@@ -49,12 +49,12 @@ class Context(object): ...@@ -49,12 +49,12 @@ class Context(object):
def end(self): def end(self):
if len(self.refs) > 0: if len(self.refs) > 0:
msg = "" msg = u""
for count, linenos in self.refs.itervalues(): for count, linenos in self.refs.itervalues():
msg += "\n Acquired on lines: " + ", ".join(["%d" % x for x in linenos]) msg += u"\n Acquired on lines: " + u", ".join([u"%d" % x for x in linenos])
self.errors.append("References leaked: %s" % msg) self.errors.append(u"References leaked: %s" % msg)
if self.errors: if self.errors:
return "\n".join(self.errors) return u"\n".join(self.errors)
else: else:
return None return None
...@@ -134,7 +134,7 @@ cdef int FinishContext(PyObject** ctx) except -1: ...@@ -134,7 +134,7 @@ cdef int FinishContext(PyObject** ctx) except -1:
Py_XDECREF(<object>ctx[0]) Py_XDECREF(<object>ctx[0])
ctx[0] = NULL ctx[0] = NULL
if errors: if errors:
print "%s: %s()" % pos print u"%s: %s()" % pos
print errors # raise Error(errors) print errors # raise Error(errors)
return 0 return 0
......
...@@ -483,7 +483,7 @@ if __name__ == '__main__': ...@@ -483,7 +483,7 @@ if __name__ == '__main__':
action="store_true", default=False, action="store_true", default=False,
help="only compile pyx to c, do not run C compiler or run the tests") help="only compile pyx to c, do not run C compiler or run the tests")
parser.add_option("--no-refnanny", dest="with_refnanny", parser.add_option("--no-refnanny", dest="with_refnanny",
action="store_false", default=True, action="store_false", default=(sys.version_info[0] < 3),
help="do not regression test reference counting") help="do not regression test reference counting")
parser.add_option("--sys-pyregr", dest="system_pyregr", parser.add_option("--sys-pyregr", dest="system_pyregr",
action="store_true", default=False, action="store_true", default=False,
......
cdef signed Py_ssize_t a
cdef unsigned Py_ssize_t b
cdef signed size_t c
cdef unsigned size_t d
cdef signed float e cdef signed float e
cdef unsigned float f cdef unsigned float f
cdef signed double g cdef signed double g
...@@ -17,8 +13,4 @@ _ERRORS = u""" ...@@ -17,8 +13,4 @@ _ERRORS = u"""
4:5: Unrecognised type modifier combination 4:5: Unrecognised type modifier combination
5:5: Unrecognised type modifier combination 5:5: Unrecognised type modifier combination
6:5: Unrecognised type modifier combination 6:5: Unrecognised type modifier combination
7:5: Unrecognised type modifier combination
8:5: Unrecognised type modifier combination
9:5: Unrecognised type modifier combination
10:5: Unrecognised type modifier combination
""" """
...@@ -35,6 +35,10 @@ Traceback (most recent call last): ...@@ -35,6 +35,10 @@ Traceback (most recent call last):
OverflowError: ... OverflowError: ...
""" """
# XXX This should generate a warning !!!
cdef extern from *:
ctypedef unsigned long size_t
def test(size_t i): def test(size_t i):
return i return i
......
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