Commit 70571ff4 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Working on this

parent 03e6d17c
...@@ -15,7 +15,7 @@ Unless specified, arguments are borrowed and return values are owned. This can ...@@ -15,7 +15,7 @@ Unless specified, arguments are borrowed and return values are owned. This can
Exception safety Exception safety
Helpers: Helpers:
AUTO_DECREF, autoDecref, incref AUTO_DECREF, autoDecref, incref. DecrefHandle
Invariant: all paths through a function should leave each variable with 0 net refs. (This includes paths out via exceptions.) Invariant: all paths through a function should leave each variable with 0 net refs. (This includes paths out via exceptions.)
......
...@@ -2,6 +2,10 @@ handle SIGUSR2 pass nostop noprint ...@@ -2,6 +2,10 @@ handle SIGUSR2 pass nostop noprint
skip file /usr/include/c++/4.8/bits/stl_vector.h skip file /usr/include/c++/4.8/bits/stl_vector.h
skip file /usr/include/c++/4.9/bits/stl_vector.h skip file /usr/include/c++/4.9/bits/stl_vector.h
skip file /usr/include/c++/4.8/bits/unique_ptr.h
skip file /usr/include/c++/4.9/bits/unique_ptr.h
skip file /usr/include/c++/4.8/bits/move.h
skip file /usr/include/c++/4.9/bits/move.h
skip pyston::ArgPassSpec::ArgPassSpec(int, int, bool, bool) skip pyston::ArgPassSpec::ArgPassSpec(int, int, bool, bool)
skip pyston::InternedString::getBox() const skip pyston::InternedString::getBox() const
......
...@@ -24,16 +24,20 @@ def make_closure(f): ...@@ -24,16 +24,20 @@ def make_closure(f):
return r return r
return inner return inner
# The standard case, when the function is obtained via standard evaluation rules: def f():
class C(object): # The standard case, when the function is obtained via standard evaluation rules:
class C(object):
@make_closure @make_closure
def f(self, other_arg=2.5**10): def f(self, other_arg=2.5**10):
print "f" print "f"
print other_arg print other_arg
del C.f del C.f
print other_arg print other_arg
c = C() c = C()
c.f() c.f()
f()
f()
f()
def f(): def f():
class C(object): class C(object):
...@@ -53,6 +57,7 @@ def f(): ...@@ -53,6 +57,7 @@ def f():
print e print e
f() f()
f() f()
f()
def f(): def f():
class C(object): class C(object):
...@@ -73,6 +78,7 @@ def f(): ...@@ -73,6 +78,7 @@ def f():
print e print e
f() f()
f() f()
f()
def f(): def f():
class C(object): class C(object):
...@@ -92,9 +98,12 @@ def f(): ...@@ -92,9 +98,12 @@ def f():
print e print e
f() f()
f() f()
f()
def f(): def f():
class C(object):
pass
class D(object): class D(object):
@make_closure @make_closure
def __get__(self, obj, type, other_arg=2.4**10): def __get__(self, obj, type, other_arg=2.4**10):
...@@ -125,14 +134,41 @@ def f(): ...@@ -125,14 +134,41 @@ def f():
print c.x print c.x
f() f()
f() f()
f()
# Deleting the descriptor object itself:
def f():
class C(object):
pass
class D(object):
def __get__(self, obj, type, other_arg=2.4**10):
print "D.__get__"
print other_arg
del C.x
print other_arg
sys._clear_type_cache()
print other_arg
return 1
C.x = D()
c = C()
print c.x
print c.x
f()
f()
f()
# TODO: lots of other cases that could/should get tested.
# Related: # Related:
@make_closure def f():
def f(a1=2.0**10, a2=2.1**10): @make_closure
def g(a1=2.0**10, a2=2.1**10):
f.func_defaults = () f.func_defaults = ()
print a1, a2 print a1, a2
del globals()['f'] del globals()['f']
g()
f()
f()
f() f()
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