Commit d36f3b8a authored by Robert Bradshaw's avatar Robert Bradshaw

-devel mergeback

parents 749cc80e 6b86bb18
......@@ -15,3 +15,5 @@ a4abf0156540db4d3ebaa95712b65811c43c5acb 0.11-beta
6454db601984145f38e28d34176fca8a3a22329c 0.11.1
af6f1bed8cd40a2edefb57d3eacbc9274a8788b4 0.11.2.rc1
15ad532e2127840ae09dfbe46ccc80ac8c562f99 0.11.2
eb00d00a73c13b6aa8b440fe07cd7acb52a060e8 0.11.3.rc0
7c695fe49fd6912f52d995fe512d66baacf90ee6 0.11.3
......@@ -150,6 +150,20 @@ def warning(position, message, level=0):
echo_file.write(line)
return warn
_warn_once_seen = {}
def warn_once(position, message, level=0):
if level < LEVEL or message in _warn_once_seen:
return
warn = CompileWarning(position, message)
line = "warning: %s\n" % warn
if listing_file:
listing_file.write(line)
if echo_file:
echo_file.write(line)
_warn_once_seen[message] = True
return warn
# These functions can be used to momentarily suppress errors.
error_stack = []
......
......@@ -4,7 +4,7 @@
import operator
from Errors import error, warning, InternalError
from Errors import error, warning, warn_once, InternalError
from Errors import hold_errors, release_errors, held_errors, report_error
from Code import UtilityCode
import StringEncoding
......@@ -781,6 +781,7 @@ class StringNode(ConstNode):
# Arrange for a Python version of the string to be pre-allocated
# when coercing to a Python type.
if dst_type.is_pyobject and not self.type.is_pyobject:
warn_once(self.pos, "String literals will no longer be Py3 bytes in Cython 0.12.", 1)
node = self.as_py_string_node(env)
else:
node = self
......
......@@ -1029,14 +1029,11 @@ class FuncDefNode(StatNode, BlockNode):
is_getbuffer_slot = (self.entry.name == "__getbuffer__" and
self.entry.scope.is_c_class_scope)
if code.globalstate.directives['profile'] is None:
profile = 'inline' not in self.modifiers and not lenv.nogil
else:
profile = code.globalstate.directives['profile']
if profile and lenv.nogil:
error(self.pos, "Cannot profile nogil function.")
profile = code.globalstate.directives['profile']
if profile:
code.globalstate.use_utility_code(trace_utility_code)
if lenv.nogil:
error(self.pos, "Cannot profile nogil function.")
code.globalstate.use_utility_code(profile_utility_code)
# Generate C code for header and body of function
code.enter_cfunc_scope()
......@@ -5655,22 +5652,22 @@ proto="""
# Note that cPython ignores PyTrace_EXCEPTION,
# but maybe some other profilers don't.
trace_utility_code = UtilityCode(proto="""
#ifndef CYTHON_TRACING
#define CYTHON_TRACING 1
profile_utility_code = UtilityCode(proto="""
#ifndef CYTHON_PROFILE
#define CYTHON_PROFILE 1
#endif
#ifndef CYTHON_TRACING_REUSE_FRAME
#define CYTHON_TRACING_REUSE_FRAME 0
#ifndef CYTHON_PROFILE_REUSE_FRAME
#define CYTHON_PROFILE_REUSE_FRAME 0
#endif
#if CYTHON_TRACING
#if CYTHON_PROFILE
#include "compile.h"
#include "frameobject.h"
#include "traceback.h"
#if CYTHON_TRACING_REUSE_FRAME
#if CYTHON_PROFILE_REUSE_FRAME
#define CYTHON_FRAME_MODIFIER static
#define CYTHON_FRAME_DEL
#else
......@@ -5682,12 +5679,12 @@ trace_utility_code = UtilityCode(proto="""
static PyCodeObject *%(FRAME_CODE)s = NULL; \\
CYTHON_FRAME_MODIFIER PyFrameObject *%(FRAME)s = NULL; \\
int __Pyx_use_tracing = 0; \\
if (PyThreadState_GET()->use_tracing && PyThreadState_GET()->c_profilefunc) { \\
if (unlikely(PyThreadState_GET()->use_tracing && PyThreadState_GET()->c_profilefunc)) { \\
__Pyx_use_tracing = __Pyx_TraceSetupAndCall(&%(FRAME_CODE)s, &%(FRAME)s, funcname, srcfile, firstlineno); \\
}
#define __Pyx_TraceException() \\
if (__Pyx_use_tracing && PyThreadState_GET()->use_tracing && PyThreadState_GET()->c_profilefunc) { \\
if (unlikely(__Pyx_use_tracing( && PyThreadState_GET()->use_tracing && PyThreadState_GET()->c_profilefunc) { \\
PyObject *exc_info = __Pyx_GetExceptionTuple(); \\
if (exc_info) { \\
PyThreadState_GET()->c_profilefunc( \\
......@@ -5697,7 +5694,7 @@ if (__Pyx_use_tracing && PyThreadState_GET()->use_tracing && PyThreadState_GET()
}
#define __Pyx_TraceReturn(result) \\
if (__Pyx_use_tracing && PyThreadState_GET()->use_tracing && PyThreadState_GET()->c_profilefunc) { \\
if (unlikely(__Pyx_use_tracing) && PyThreadState_GET()->use_tracing && PyThreadState_GET()->c_profilefunc) { \\
PyThreadState_GET()->c_profilefunc( \\
PyThreadState_GET()->c_profileobj, %(FRAME)s, PyTrace_RETURN, (PyObject*)result); \\
CYTHON_FRAME_DEL; \\
......@@ -5710,7 +5707,7 @@ static int __Pyx_TraceSetupAndCall(PyCodeObject** code, PyFrameObject** frame, c
#define __Pyx_TraceCall(funcname, srcfile, firstlineno)
#define __Pyx_TraceException()
#define __Pyx_TraceReturn(result)
#endif /* CYTHON_TRACING */
#endif /* CYTHON_PROFILE */
"""
% {
"FRAME": Naming.frame_cname,
......@@ -5718,14 +5715,14 @@ static int __Pyx_TraceSetupAndCall(PyCodeObject** code, PyFrameObject** frame, c
},
impl = """
#if CYTHON_TRACING
#if CYTHON_PROFILE
static int __Pyx_TraceSetupAndCall(PyCodeObject** code,
PyFrameObject** frame,
const char *funcname,
const char *srcfile,
int firstlineno) {
if (*frame == NULL || !CYTHON_TRACING_REUSE_FRAME) {
if (*frame == NULL || !CYTHON_PROFILE_REUSE_FRAME) {
if (*code == NULL) {
*code = __Pyx_createFrameCodeObject(funcname, srcfile, firstlineno);
if (*code == NULL) return 0;
......@@ -5785,7 +5782,7 @@ bad:
return py_code;
}
#endif /* CYTHON_TRACING */
#endif /* CYTHON_PROFILE */
""" % {
'EMPTY_TUPLE' : Naming.empty_tuple,
'EMPTY_BYTES' : Naming.empty_bytes,
......
......@@ -67,11 +67,11 @@ option_defaults = {
'wraparound' : True,
'c99_complex' : False, # Don't use macro wrappers for complex arith, not sure what to name this...
'callspec' : "",
'profile': None,
'profile': False,
}
# Override types possibilities above, if needed
option_types = { 'profile': bool }
option_types = {}
for key, val in option_defaults.items():
if key not in option_types:
......
version = '0.11.2'
version = '0.11.3'
......@@ -124,7 +124,7 @@ cdef extern from "numpy/arrayobject.h":
cdef int itemsize "elsize"
cdef char byteorder
cdef object fields
cdef object names
cdef tuple names
ctypedef extern class numpy.flatiter [object PyArrayIterObject]:
# Use through macros
......@@ -696,10 +696,11 @@ cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset
cdef tuple i
cdef int endian_detector = 1
cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
cdef tuple fields
for i in descr.fields.itervalues():
child = i[0]
new_offset = i[1]
for childname in descr.names:
fields = descr.fields[childname]
child, new_offset = fields
if (end - f) - (new_offset - offset[0]) < 15:
raise RuntimeError("Format string allocated too short, see comment in numpy.pxd")
......
......@@ -18,6 +18,7 @@ py_include_dirs = [
"/Library/Frameworks/Python.framework/Versions/%s/Headers" % version_string
]
osx_version = os.popen('sw_vers | grep ProductVersion').read().split()[1]
# MACOSX_DEPLOYMENT_TARGET can be set to 10.3 in most cases.
# But for the built-in Python 2.5.1 on Leopard, it needs to be set for 10.5.
# This looks like a bug that will be fixed in 2.5.2. If Apple updates their
......@@ -28,12 +29,14 @@ leopard_python_prefix = '/System/Library/Frameworks/Python.framework/Versions/2.
full_version = "%s.%s.%s" % sys.version_info[:3]
if python_prefix == leopard_python_prefix and full_version == '2.5.1':
os.environ["MACOSX_DEPLOYMENT_TARGET"] = "10.5"
elif osx_version >= "10.6":
os.environ["MACOSX_DEPLOYMENT_TARGET"] = "10.4"
else:
os.environ["MACOSX_DEPLOYMENT_TARGET"] = "10.3"
compilers = ["gcc", "g++"]
compiler_options = \
"-g -c -fno-strict-aliasing -Wno-long-double -no-cpp-precomp " \
"-g -c -fno-strict-aliasing -no-cpp-precomp " \
"-mno-fused-madd -fno-common -dynamic " \
.split()
if gcc_pendantic:
......
......@@ -5,7 +5,7 @@ PYTHON := /Local/Build/Pythonic/python/2.3
INCLUDE := -I$(PYTHON) -I$(PYTHON)/Include -I$(PYTHON)/Mac/Include
CCOPTS := -fno-strict-aliasing -Wno-long-double -no-cpp-precomp \
CCOPTS := -fno-strict-aliasing -no-cpp-precomp \
-mno-fused-madd -fno-common -dynamic
LDOPTS := -Wl,-F.,-w -bundle -framework Python -framework Carbon
......
......@@ -61,7 +61,7 @@ class Context(object):
cdef void report_unraisable(object e):
try:
print "refnanny raised an exception: %s" % e
print u"refnanny raised an exception: %s" % e
except:
pass # We absolutely cannot exit with an exception
......
......@@ -3,7 +3,7 @@ include COPYING.txt LICENSE.txt Makefile
recursive-include .hg *
include .hgignore .hgtags
include setup.py
include bin/cython
include bin/*
include cython.py
include Cython/Compiler/Lexicon.pickle
recursive-include Cython *.pyx *.pxd
......@@ -13,10 +13,11 @@ include Demos/*.pyx
include Demos/*.py
include Demos/callback/*
include Demos/embed/*
include Demos/freeze/*
include Demos/Setup.py
include Demos/Makefile*
include Tools/*
recursive-include tests *.pyx *.pxd *.pxi *.h *.BROKEN
recursive-include tests *.pyx *.pxd *.pxi *.py *.h *.BROKEN bugs.txt
include runtests.py
include Cython/Mac/Makefile
......
......@@ -55,6 +55,11 @@ def pyx_to_dll(filename, ext = None, force_rebuild = 0,
build = dist.get_command_obj('build')
build.build_base = pyxbuild_dir
config_files = dist.find_config_files()
try: config_files.remove('setup.cfg')
except ValueError: pass
dist.parse_config_files(config_files)
try:
ok = dist.parse_command_line()
except DistutilsArgError:
......
......@@ -117,7 +117,7 @@ def handle_dependencies(pyxfilename):
# be tricked into rebuilding it.
for file in files:
if newer(file, pyxfilename):
print "Rebuilding because of ", file
print("Rebuilding because of ", file)
filetime = os.path.getmtime(file)
os.utime(pyxfilename, (filetime, filetime))
_test_files.append(file)
......@@ -141,7 +141,7 @@ def build_module(name, pyxfilename, pyxbuild_dir=None):
try:
os.remove(path)
except IOError:
print "Couldn't remove ", path
print("Couldn't remove ", path)
return so_path
......@@ -168,7 +168,7 @@ class PyxImporter(object):
if fullname in sys.modules:
return None
if DEBUG_IMPORT:
print "SEARCHING", fullname, package_path
print("SEARCHING", fullname, package_path)
if '.' in fullname:
mod_parts = fullname.split('.')
package = '.'.join(mod_parts[:-1])
......@@ -226,7 +226,7 @@ class PyImporter(PyxImporter):
# prevent infinite recursion
return None
if DEBUG_IMPORT:
print "trying import of module %s" % fullname
print("trying import of module", fullname)
if fullname in self.uncompilable_modules:
path, last_modified = self.uncompilable_modules[fullname]
try:
......@@ -243,7 +243,7 @@ class PyImporter(PyxImporter):
importer = self.super.find_module(fullname, package_path)
if importer is not None:
if DEBUG_IMPORT:
print "importer found"
print("importer found")
try:
if importer.init_path:
path = importer.init_path
......
......@@ -8,6 +8,3 @@ unsignedbehaviour_T184
funcexc_iter_T228
bad_c_struct_T252
missing_baseclass_in_predecl_T262
# Not yet enabled
profile_test
......@@ -17,6 +17,8 @@ try:
import numpy as np
__doc__ = u"""
>>> assert_dtype_sizes()
>>> basic()
[[0 1 2 3 4]
[5 6 7 8 9]]
......@@ -199,12 +201,30 @@ try:
1,1
1,1
8,16
>>> test_point_record()
array([(0.0, 0.0), (1.0, -1.0), (2.0, -2.0)],
dtype=[('x', '!f8'), ('y', '!f8')])
"""
except:
__doc__ = u""
def assert_dtype_sizes():
assert sizeof(np.int8_t) == 1
assert sizeof(np.int16_t) == 2
assert sizeof(np.int32_t) == 4
assert sizeof(np.int64_t) == 8
assert sizeof(np.uint8_t) == 1
assert sizeof(np.uint16_t) == 2
assert sizeof(np.uint32_t) == 4
assert sizeof(np.uint64_t) == 8
assert sizeof(np.float32_t) == 4
assert sizeof(np.float64_t) == 8
assert sizeof(np.complex64_t) == 8
assert sizeof(np.complex128_t) == 16
def ndarray_str(arr):
u"""
Since Py2.3 doctest don't support <BLANKLINE>, manually replace blank lines
......@@ -392,4 +412,15 @@ def test_complextypes():
print "%d,%d" % (sizeof(x64), sizeof(x128))
cdef struct Point:
np.float64_t x, y
def test_point_record():
cdef np.ndarray[Point] test
Point_dtype = np.dtype([('x', np.float64), ('y', np.float64)])
test = np.zeros(3, Point_dtype)
cdef int i
for i in range(3):
test[i].x = i
test[i].y = -i
print repr(test).replace('<', '!').replace('>', '!')
# cython: profile = True
__doc__ = u"""
>>> import os, tempfile, cProfile as profile, pstats
>>> statsfile = tempfile.mkstemp()[1]
......@@ -9,9 +11,7 @@ __doc__ = u"""
>>> short_stats['f_cdef']
100
>>> short_stats['f_inline']
Traceback (most recent call last):
...
KeyError: 'f_inline'
100
>>> short_stats['f_inline_prof']
100
>>> short_stats['f_noprof']
......
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