Commit 37fb8a2d authored by mattip's avatar mattip

MAINT: cannot use local enum in __Pyx functions

parent b27baf04
...@@ -3061,17 +3061,17 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -3061,17 +3061,17 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
# check_size # check_size
if not type.is_external or type.is_subclassed: if not type.is_external or type.is_subclassed:
cs = '__PYX_CHECKSIZE_STRICT' cs = 0
elif type.check_size == b'min': elif type.check_size == b'min':
cs = '__PYX_CHECKSIZE_MIN' cs = 1
elif type.check_size is True: elif type.check_size is True:
cs = '__PYX_CHECKSIZE_STRICT' cs = 0
elif type.check_size is False: elif type.check_size is False:
cs = '__PYX_CHECKSIZE_LOOSE' cs = 2
else: else:
raise AttributeError("invalid value for check_size '%r' when compiling " raise AttributeError("invalid value for check_size '%r' when compiling "
"%s.%s" % (type.check_size, module_name, type.name)) "%s.%s" % (type.check_size, module_name, type.name))
code.putln('%s);' % cs) code.putln('%d);' % cs)
code.putln(' if (!%s) %s' % (type.typeptr_cname, error_code)) code.putln(' if (!%s) %s' % (type.typeptr_cname, error_code))
......
...@@ -308,22 +308,22 @@ set_path: ...@@ -308,22 +308,22 @@ set_path:
/////////////// TypeImport.proto /////////////// /////////////// TypeImport.proto ///////////////
typedef enum { /* What to do if tp_basicsize is different from size? */
__PYX_CHECKSIZE_STRICT, /* Error */
__PYX_CHECKSIZE_MIN, /* Error if tp_basicsize is smaller, warn if larger */
__PYX_CHECKSIZE_LOOSE, /* Error if tp_basicsize is smaller */
} __pyx_CheckSizeState;
static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, int check_size); /*proto*/
static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, __pyx_CheckSizeState check_size); /*proto*/
/////////////// TypeImport /////////////// /////////////// TypeImport ///////////////
#ifndef __PYX_HAVE_RT_ImportType #ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType #define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name, static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
size_t size, __pyx_CheckSizeState check_size) size_t size, int check_size)
{ {
/*
* check_size tells what to do if tp_basicsize is different from size:
* 0 - Error (originates in check_size=True)
* 1 - Error if tp_basicsize is smaller, warn if larger (originates in check_size='min')
* 2 - Error if tp_basicsize is smaller (originates in check_size=False)
*/
PyObject *result = 0; PyObject *result = 0;
char warning[200]; char warning[200];
Py_ssize_t basicsize; Py_ssize_t basicsize;
...@@ -359,21 +359,21 @@ static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, ...@@ -359,21 +359,21 @@ static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name,
module_name, class_name, size, basicsize); module_name, class_name, size, basicsize);
goto bad; goto bad;
} }
if (check_size == __PYX_CHECKSIZE_STRICT && (size_t)basicsize != size) { if (check_size == 0 && (size_t)basicsize != size) {
PyErr_Format(PyExc_ValueError, PyErr_Format(PyExc_ValueError,
"%.200s.%.200s size changed, may indicate binary incompatibility. " "%.200s.%.200s size changed, may indicate binary incompatibility. "
"Expected %zd from C header, got %zd from PyObject", "Expected %zd from C header, got %zd from PyObject",
module_name, class_name, size, basicsize); module_name, class_name, size, basicsize);
goto bad; goto bad;
} }
else if (check_size == __PYX_CHECKSIZE_MIN && (size_t)basicsize > size) { else if (check_size == 1 && (size_t)basicsize > size) {
PyOS_snprintf(warning, sizeof(warning), PyOS_snprintf(warning, sizeof(warning),
"%s.%s size changed, may indicate binary incompatibility. " "%s.%s size changed, may indicate binary incompatibility. "
"Expected %zd from C header, got %zd from PyObject", "Expected %zd from C header, got %zd from PyObject",
module_name, class_name, size, basicsize); module_name, class_name, size, basicsize);
if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
} }
/* __PYX_CHECKSIZE_LOOSE does not warn nor error */ /* check_size == 2 does not warn nor error */
return (PyTypeObject *)result; return (PyTypeObject *)result;
bad: bad:
Py_XDECREF(result); Py_XDECREF(result);
......
...@@ -1735,6 +1735,9 @@ class EndToEndTest(unittest.TestCase): ...@@ -1735,6 +1735,9 @@ class EndToEndTest(unittest.TestCase):
old_path = os.environ.get('PYTHONPATH') old_path = os.environ.get('PYTHONPATH')
env = dict(os.environ) env = dict(os.environ)
env['PYTHONPATH'] = self.cython_syspath + os.pathsep + (old_path or '') env['PYTHONPATH'] = self.cython_syspath + os.pathsep + (old_path or '')
cmd = []
out = []
err = []
for command_no, command in enumerate(filter(None, commands.splitlines()), 1): for command_no, command in enumerate(filter(None, commands.splitlines()), 1):
with self.stats.time('%s(%d)' % (self.name, command_no), 'c', with self.stats.time('%s(%d)' % (self.name, command_no), 'c',
'etoe-build' if ' setup.py ' in command else 'etoe-run'): 'etoe-build' if ' setup.py ' in command else 'etoe-run'):
...@@ -1743,11 +1746,15 @@ class EndToEndTest(unittest.TestCase): ...@@ -1743,11 +1746,15 @@ class EndToEndTest(unittest.TestCase):
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
shell=True, shell=True,
env=env) env=env)
out, err = p.communicate() _out, _err = p.communicate()
cmd.append(command)
out.append(_out)
err.append(_err)
res = p.returncode res = p.returncode
if res != 0: if res != 0:
sys.stderr.write("%s\n%s\n%s\n" % ( for c, o, e in zip(cmd, out, err):
command, self._try_decode(out), self._try_decode(err))) sys.stderr.write("%s\n%s\n%s\n\n" % (
c, self._try_decode(o), self._try_decode(e)))
self.assertEqual(0, res, "non-zero exit status") self.assertEqual(0, res, "non-zero exit status")
self.success = True self.success = True
......
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