Commit 0dc46274 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge commit '11522d' into refcounting

parents 0545a7d1 11522d5e
# expected: fail
import unittest
from test import test_support as support
......
# expected: fail
"""test script for a few new invalid token catches"""
import unittest
......
# expected: fail
import unittest
from test import test_support
......
# expected: fail
import os
import sys
import time
......
# expected: fail
"""Unit tests for memory-based file-like objects.
StringIO -- for unicode strings
BytesIO -- for bytes
......
# expected: fail
# test for xml.dom.minidom
import pickle
......
# expected: fail
# This set of tests exercises the backward-compatibility class
# in mailbox.py (the ones without write support).
......
# expected: fail
# -*- coding: koi8-r -*-
import unittest
......
# expected: fail
# Test the Unicode versions of normal file functions
# open, os.open, os.stat. os.listdir, os.rename, os.remove, os.mkdir, os.chdir, os.rmdir
import sys, os, unittest
......
# expected: fail
# -*- coding: iso-8859-1 -*-
import unittest
import shlex
......
# expected: fail
import unittest
from test import test_support
import smtplib
......
# expected: fail
import os
import array
import unittest
......
# expected: fail
"""Unit tests for socket timeout feature."""
import unittest
......
# expected: fail
from test.test_support import TESTFN, run_unittest
import unittest
from test import audiotests
......
# expected: fail
"""Unit tests for the with statement specified in PEP 343."""
......
# expected: fail
from __future__ import nested_scopes # Backward compat for 2.1
from unittest import TestCase
from wsgiref.util import setup_testing_defaults
......@@ -114,11 +113,6 @@ class IntegrationTests(TestCase):
out, err = run_amock()
self.check_hello(out)
def test_request_length(self):
out, err = run_amock(data="GET " + ("x" * 65537) + " HTTP/1.0\n\n")
self.assertEqual(out.splitlines()[0],
"HTTP/1.0 414 Request-URI Too Long")
def test_validated_hello(self):
out, err = run_amock(validator(hello_app))
# the middleware doesn't support len(), so content-length isn't there
......
......@@ -14,6 +14,7 @@
#include "core/common.h"
#include "core/types.h"
#include "runtime/int.h"
#include "runtime/objmodel.h"
#include "runtime/types.h"
......@@ -54,33 +55,33 @@ extern "C" Box* boolNew(Box* cls, Box* val) {
}
extern "C" Box* boolAnd(BoxedBool* lhs, BoxedBool* rhs) {
if (lhs->cls != bool_cls)
if (!PyBool_Check(lhs))
raiseExcHelper(TypeError, "descriptor '__and__' requires a 'bool' object but received a '%s'",
getTypeName(lhs));
if (rhs->cls != bool_cls)
return incref(NotImplemented);
if (!PyBool_Check(rhs))
return intAnd(lhs, rhs);
return boxBool(lhs->n && rhs->n);
}
extern "C" Box* boolOr(BoxedBool* lhs, BoxedBool* rhs) {
if (lhs->cls != bool_cls)
if (!PyBool_Check(lhs))
raiseExcHelper(TypeError, "descriptor '__or__' requires a 'bool' object but received a '%s'", getTypeName(lhs));
if (rhs->cls != bool_cls)
return incref(NotImplemented);
if (!PyBool_Check(rhs))
return intOr(lhs, rhs);
return boxBool(lhs->n || rhs->n);
}
extern "C" Box* boolXor(BoxedBool* lhs, BoxedBool* rhs) {
if (lhs->cls != bool_cls)
if (!PyBool_Check(lhs))
raiseExcHelper(TypeError, "descriptor '__xor__' requires a 'bool' object but received a '%s'",
getTypeName(lhs));
if (rhs->cls != bool_cls)
return incref(NotImplemented);
if (!PyBool_Check(rhs))
return intXor(lhs, rhs);
return boxBool(lhs->n ^ rhs->n);
}
......@@ -97,9 +98,10 @@ void setupBool() {
bool_cls->giveAttr("__new__",
new BoxedFunction(FunctionMetadata::create((void*)boolNew, UNKNOWN, 2, false, false), { None }));
bool_cls->giveAttr("__and__", new BoxedFunction(FunctionMetadata::create((void*)boolAnd, BOXED_BOOL, 2)));
bool_cls->giveAttr("__or__", new BoxedFunction(FunctionMetadata::create((void*)boolOr, BOXED_BOOL, 2)));
bool_cls->giveAttr("__xor__", new BoxedFunction(FunctionMetadata::create((void*)boolXor, BOXED_BOOL, 2)));
// TODO: type specialize
bool_cls->giveAttr("__and__", new BoxedFunction(FunctionMetadata::create((void*)boolAnd, UNKNOWN, 2)));
bool_cls->giveAttr("__or__", new BoxedFunction(FunctionMetadata::create((void*)boolOr, UNKNOWN, 2)));
bool_cls->giveAttr("__xor__", new BoxedFunction(FunctionMetadata::create((void*)boolXor, UNKNOWN, 2)));
bool_cls->freeze();
bool_cls->tp_hash = (hashfunc)bool_hash;
......
......@@ -595,7 +595,14 @@ Box* instanceDelattr(Box* _inst, Box* _attr) {
return runtimeCall(delattr, ArgPassSpec(1), _attr, NULL, NULL, NULL, NULL);
}
_inst->delattr(attr, NULL);
if (_inst->hasattr(attr))
_inst->delattr(attr, NULL);
else {
BoxedClassobj* clsobj = (BoxedClassobj*)inst->inst_cls;
RELEASE_ASSERT(PyClass_Check(clsobj), "");
raiseExcHelper(AttributeError, "%.50s instance has no attribute '%.400s'", clsobj->name->c_str(),
attr->c_str());
}
return None;
}
......
......@@ -46,8 +46,10 @@ extern "C" Box* intGe(BoxedInt* lhs, Box* rhs);
extern "C" Box* intLShift(BoxedInt* lhs, Box* rhs);
extern "C" Box* intMod(BoxedInt* lhs, Box* rhs);
extern "C" Box* intMul(BoxedInt* lhs, Box* rhs);
extern "C" Box* intOr(BoxedInt* lhs, Box* rhs);
extern "C" Box* intRShift(BoxedInt* lhs, Box* rhs);
extern "C" Box* intSub(BoxedInt* lhs, Box* rhs);
extern "C" Box* intXor(BoxedInt* lhs, Box* rhs);
extern "C" Box* intInvert(BoxedInt* v);
extern "C" Box* intPos(BoxedInt* v);
extern "C" Box* intNeg(BoxedInt* v);
......
......@@ -980,7 +980,7 @@ extern "C" Box* PyList_GetSlice(PyObject* a, Py_ssize_t ilow, Py_ssize_t ihigh)
return listGetitemSlice<CAPI>(self, new BoxedSlice(boxInt(ilow), boxInt(ihigh), boxInt(1)));
}
static inline int list_contains_shared(BoxedList* self, Box* elt) {
static inline int listContainsShared(BoxedList* self, Box* elt) {
assert(PyList_Check(self));
int size = self->size;
......@@ -1002,7 +1002,12 @@ static inline int list_contains_shared(BoxedList* self, Box* elt) {
}
static int list_contains(PyListObject* a, PyObject* el) noexcept {
return list_contains_shared((BoxedList*)a, el);
try {
return listContainsShared((BoxedList*)a, el);
} catch (ExcInfo e) {
setCAPIException(e);
return -1;
}
}
static PyObject* list_repeat(PyListObject* a, Py_ssize_t n) noexcept {
......@@ -1044,7 +1049,7 @@ static PyObject* list_repeat(PyListObject* a, Py_ssize_t n) noexcept {
}
Box* listContains(BoxedList* self, Box* elt) {
return boxBool(list_contains_shared(self, elt));
return boxBool(listContainsShared(self, elt));
}
Box* listCount(BoxedList* self, Box* elt) {
......
......@@ -121,10 +121,10 @@ Box* superGetattribute(Box* _s, Box* _attr) {
}
}
Box* r = typeLookup(s->cls, attr);
// TODO implement this
RELEASE_ASSERT(r, "should call the equivalent of objectGetattr here");
return processDescriptor(r, s, s->cls);
Box* rtn = PyObject_GenericGetAttr(s, attr);
if (!rtn)
throwCAPIException();
return rtn;
}
Box* super_getattro(Box* _s, Box* _attr) noexcept {
......
......@@ -37,7 +37,7 @@ test_builtin execfile scoping issue
test_bz2 [unknown]
test_capi [unknown]
test_cd [unknown]
test_cfgparser [unknown]
test_cfgparser works when run from inside the from_cpython dir
test_cgi [unknown]
test_class needs ellipsis
test_cl [unknown]
......@@ -57,7 +57,7 @@ test_codecmaps_tw [unknown]
test_codecs [unknown]
test_codeop [unknown]
test_code [unknown]
test_coding [unknown]
test_coding works when run from inside the from_cpython dir
test_coercion 1**1L, divmod(1, 1L); some unknown bug
test_collections assertion failed when doing vars(collections.namedtuple('Point', 'x y')(11, 12))
test_compileall [unknown]
......@@ -77,7 +77,6 @@ test_decorators decorator bug -- we evaluate decorator obj and its args
test_deque couple unknown issues
test_descrtut `exec in DefaultDict()`
test_descr wontfix: crashes at "self.__dict__ = self"
test_dictcomps we need to disallow assigning to dictcomps
test_dict misc failures related to things like gc, abc, comparisons, detecting mutations during iterations
test_dictviews segfault calling repr on recursive dictview. remove test/tests/test_dictview.py when the orig test passes
test_difflib [unknown]
......@@ -90,7 +89,6 @@ test_email_codecs [unknown]
test_email_renamed [unknown]
test_email [unknown]
test_enumerate assert instead of exception in BoxedEnumerate
test_eof [unknown]
test_exceptions we are missing recursion-depth checking
test_extcall f(**kw) crashes if kw isn't a dict
test_file2k we abort when you try to open() a directory
......@@ -134,15 +132,11 @@ test_linuxaudiodev [unknown]
test_list longs as slice indices
test__locale No module named _locale
test_locale [unknown]
test_longexp [unknown]
test_long_future [unknown]
test_macos Not really a failure, but it tries to skip itself and we don't support that
test_macostools Not really a failure, but it tries to skip itself and we don't support that
test_mailbox [unknown]
test_marshal [unknown]
test_memoryio [unknown]
test_memoryview [unknown]
test_minidom [unknown]
test_modulefinder [unknown]
test_module unicode docstrings
test_msilib [unknown]
......@@ -151,20 +145,17 @@ test_multiprocessing [unknown]
test_mutants unknown failure
test_new [unknown]
test_nis [unknown]
test_old_mailbox [unknown]
test_optparse assertion instead of exceptions for long("invalid number")
test_ossaudiodev [unknown]
test_os [unknown]
test_parser [unknown]
test_pdb [unknown]
test_peepholer [unknown]
test_pep263 [unknown]
test_pep277 segfaults
test_pep352 various unique bugs
test_pickletools [unknown]
test_pickle unknown
test_pkg unknown bug
test_poplib [unknown]
test_poplib SSLError (but only on CI)
test_pprint [unknown]
test_profile [unknown]
test_py3kwarn [unknown]
......@@ -181,9 +172,7 @@ test_sax [unknown]
test_scope eval of code object from existing function (not currently supported)
test_scriptpackages [unknown]
test_shelve [unknown]
test_shlex [unknown]
test_site [unknown]
test_smtpnet [unknown]
test_socketserver [unknown]
test_socket [unknown]
test_sort argument specification issue in listSort?
......@@ -192,7 +181,6 @@ test_ssl [unknown]
test_startfile [unknown]
test_str memory leak?
test_structmembers [unknown]
test_struct [unknown]
test_subprocess exit code 141 [sigpipe?], no error message
test_sunaudiodev [unknown]
test_sunau [unknown]
......@@ -213,7 +201,6 @@ test_threading_local [unknown]
test_threading [unknown]
test_threadsignals [unknown]
test_thread [unknown]
test_timeout [unknown]
test_tk [unknown]
test_tokenize [unknown]
test_tools [unknown]
......@@ -235,17 +222,14 @@ test_urllibnet [unknown]
test_userdict segfault: repr of recursive dict?
test_userlist slice(1L, 1L)
test_userstring float(1L); hangs in test_replace
test_uuid long("invalid number")
test_uuid segfault in ctypes (but only on CI)
test_wait3 [unknown]
test_wait4 [unknown]
test_warnings [unknown]
test_wave [unknown]
test_weakref weird function-picking bug (something around float.__add__)
test_weakset unknown issues
test_winreg [unknown]
test_winsound [unknown]
test_with weird codegen assert
test_wsgiref unknown issue
test_xml_etree_c [unknown]
test_xml_etree [unknown]
test_xmlrpc [unknown]
......
../../from_cpython/Lib/test/audiodata
\ No newline at end of file
../../from_cpython/Lib/test/xmltestdata
\ No newline at end of file
......@@ -31,10 +31,14 @@ print isinstance(True, int)
print isinstance(False, int)
for lhs in (True, False):
for rhs in (True, False):
print lhs | rhs
print lhs & rhs
print lhs ^ rhs
for rhs in (True, False, 1, 1.0):
try:
print lhs.__and__(rhs), lhs.__or__(rhs), lhs.__xor__(rhs)
print lhs | rhs
print lhs & rhs
print lhs ^ rhs
except Exception as e:
print e
print range(False, True, True)
......
......@@ -211,3 +211,11 @@ print l
"""
print repr(list.__hash__)
class RaisingCmp(object):
def __eq__(self, other):
1/0
try:
RaisingCmp() in [1, 2, 3]
except ZeroDivisionError as e:
print e
......@@ -387,6 +387,10 @@ try:
C.doesnt_exist
except AttributeError as e:
print e
try:
del C().doesnt_exist
except AttributeError as e:
print e
class C():
......
......@@ -19,6 +19,11 @@ class C(B):
def f(self):
print "C.f()"
super(C, self).f()
print super(C, self).__thisclass__
try:
super(C, self).does_not_exist
except AttributeError as e:
print e
c = C(1, 2)
print c.arg1
......
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