Commit 51d50168 authored by Marius Wachtler's avatar Marius Wachtler

Merge pull request #1115 from undingen/cleanup_1028

Address minor comment from #1028
parents 0535bf7b 0b79eb2d
......@@ -929,17 +929,15 @@ template <ExceptionStyle S> Box* floatNew(BoxedClass* _cls, Box* a) noexcept(S =
// Roughly analogous to CPython's float_new.
// The arguments need to be unpacked from args and kwds.
static Box* floatNewPacked(BoxedClass* type, Box* args, Box* kwds) noexcept {
PyObject* x = False;
PyObject* x = False; // False is like initalizing it to 0.0 but faster because we don't need to box it in case the
// optional arg exists
static char* kwlist[2] = { NULL, NULL };
kwlist[0] = const_cast<char*>("x");
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:float", kwlist, &x))
return NULL;
if (x == NULL)
return floatNew<CAPI>(type, None);
else
return floatNew<CAPI>(type, x);
return floatNew<CAPI>(type, x);
}
PyObject* float_str_or_repr(double v, int precision, char format_code) {
......@@ -1663,7 +1661,8 @@ void setupFloat() {
float_cls->giveAttr("__divmod__", new BoxedFunction(FunctionMetadata::create((void*)floatDivmod, UNKNOWN, 2)));
float_cls->giveAttr("__rdivmod__", new BoxedFunction(FunctionMetadata::create((void*)floatRDivmod, UNKNOWN, 2)));
auto float_new = FunctionMetadata::create((void*)floatNew<CXX>, UNKNOWN, 2, false, false, ParamNames::empty(), CXX);
auto float_new = FunctionMetadata::create((void*)floatNew<CXX>, UNKNOWN, 2, false, false,
ParamNames({ "", "x" }, "", ""), CXX);
float_new->addVersion((void*)floatNew<CAPI>, UNKNOWN, CAPI);
float_cls->giveAttr("__new__", new BoxedFunction(float_new, { boxFloat(0.0) }));
......
......@@ -2921,7 +2921,8 @@ void setupStr() {
str_cls->giveAttr(md.ml_name, new BoxedMethodDescriptor(&md, str_cls));
}
auto str_new = FunctionMetadata::create((void*)strNew<CXX>, UNKNOWN, 2, false, false, ParamNames::empty(), CXX);
auto str_new = FunctionMetadata::create((void*)strNew<CXX>, UNKNOWN, 2, false, false,
ParamNames({ "", "object" }, "", ""), CXX);
str_new->addVersion((void*)strNew<CAPI>, UNKNOWN, CAPI);
str_cls->giveAttr("__new__", new BoxedFunction(str_new, { EmptyString }));
......
......@@ -141,7 +141,7 @@ import numpy as np
a = np.array([1, 2**16, 2**32], dtype=int)
s = a.astype(str)
print s
assert repr(s) == "array(['1', '65536', '4294967296'], \n dtype='|S21')"
assert repr(s) == "array(['1', '65536', '4294967296'], \\n dtype='|S21')"
"""
numpy_test = "import numpy as np; np.test(verbose=2)"
......@@ -154,7 +154,11 @@ subprocess.check_call([PYTHON_EXE, "-c", mandelbrot], cwd=CYTHON_DIR)
print_progress_header("Running NumPy str test...")
subprocess.check_call([PYTHON_EXE, "-c", mandelbrot], cwd=CYTHON_DIR)
subprocess.check_call([PYTHON_EXE, "-c", string_test], cwd=CYTHON_DIR)
# fails in release mode
#print_progress_header("Running NumPy test_abc.py test...")
#subprocess.check_call([PYTHON_EXE, os.path.join(NUMPY_DIR, "numpy/core/tests/test_abc.py")], cwd=CYTHON_DIR)
print_progress_header("Running NumPy test suite...")
# Currently we crash running the test suite. Uncomment for testing or
......
......@@ -3,6 +3,7 @@ f = 1.0
print f
print float(2)
print float(x=2)
# print f - 2
......
......@@ -10,6 +10,8 @@ print repr('"')
# print repr("'") // don't feel like handling this right now; this should print out (verbatim) "'", ie realize it can use double quotes
print repr("'\"")
print str(object="test")
print "hello world\tmore\nwords\va\fb\ao".split()
print " test ".split()
print " test ".split(' ')
......
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