Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
65810fee
Kaydet (Commit)
65810fee
authored
May 26, 2006
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
SF patch 1495675: Remove types.InstanceType and new.instance
(Collin Winter)
üst
2018831b
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
50 additions
and
146 deletions
+50
-146
libnew.tex
Doc/lib/libnew.tex
+0
-8
libtypes.tex
Doc/lib/libtypes.tex
+0
-4
copy.py
Lib/copy.py
+0
-43
dis.py
Lib/dis.py
+0
-2
new.py
Lib/new.py
+0
-1
pickle.py
Lib/pickle.py
+0
-40
pickletools.py
Lib/pickletools.py
+46
-30
test_new
Lib/test/output/test_new
+0
-1
test_new.py
Lib/test/test_new.py
+2
-12
types.py
Lib/types.py
+2
-4
xmlrpclib.py
Lib/xmlrpclib.py
+0
-1
No files found.
Doc/lib/libnew.tex
Dosyayı görüntüle @
65810fee
...
...
@@ -16,14 +16,6 @@ interpreter when the object is used.
The
\module
{
new
}
module defines the following functions:
\begin{funcdesc}
{
instance
}{
class
\optional
{
, dict
}}
This function creates an instance of
\var
{
class
}
with dictionary
\var
{
dict
}
without calling the
\method
{__
init
__
()
}
constructor. If
\var
{
dict
}
is omitted or
\code
{
None
}
, a new, empty dictionary is
created for the new instance. Note that there are no guarantees that
the object will be in a consistent state.
\end{funcdesc}
\begin{funcdesc}
{
instancemethod
}{
function, instance, class
}
This function will return a method object, bound to
\var
{
instance
}
, or
unbound if
\var
{
instance
}
is
\code
{
None
}
.
\var
{
function
}
must be
...
...
Doc/lib/libtypes.tex
Dosyayı görüntüle @
65810fee
...
...
@@ -122,10 +122,6 @@ The type for code objects such as returned by
The type of user-defined classes.
\end{datadesc}
\begin{datadesc}
{
InstanceType
}
The type of instances of user-defined classes.
\end{datadesc}
\begin{datadesc}
{
MethodType
}
The type of methods of user-defined class instances.
\end{datadesc}
...
...
Lib/copy.py
Dosyayı görüntüle @
65810fee
...
...
@@ -119,26 +119,6 @@ def _copy_with_copy_method(x):
if
PyStringMap
is
not
None
:
d
[
PyStringMap
]
=
_copy_with_copy_method
def
_copy_inst
(
x
):
if
hasattr
(
x
,
'__copy__'
):
return
x
.
__copy__
()
if
hasattr
(
x
,
'__getinitargs__'
):
args
=
x
.
__getinitargs__
()
y
=
x
.
__class__
(
*
args
)
else
:
y
=
_EmptyClass
()
y
.
__class__
=
x
.
__class__
if
hasattr
(
x
,
'__getstate__'
):
state
=
x
.
__getstate__
()
else
:
state
=
x
.
__dict__
if
hasattr
(
y
,
'__setstate__'
):
y
.
__setstate__
(
state
)
else
:
y
.
__dict__
.
update
(
state
)
return
y
d
[
types
.
InstanceType
]
=
_copy_inst
del
d
def
deepcopy
(
x
,
memo
=
None
,
_nil
=
[]):
...
...
@@ -273,29 +253,6 @@ def _keep_alive(x, memo):
# aha, this is the first one :-)
memo
[
id
(
memo
)]
=
[
x
]
def
_deepcopy_inst
(
x
,
memo
):
if
hasattr
(
x
,
'__deepcopy__'
):
return
x
.
__deepcopy__
(
memo
)
if
hasattr
(
x
,
'__getinitargs__'
):
args
=
x
.
__getinitargs__
()
args
=
deepcopy
(
args
,
memo
)
y
=
x
.
__class__
(
*
args
)
else
:
y
=
_EmptyClass
()
y
.
__class__
=
x
.
__class__
memo
[
id
(
x
)]
=
y
if
hasattr
(
x
,
'__getstate__'
):
state
=
x
.
__getstate__
()
else
:
state
=
x
.
__dict__
state
=
deepcopy
(
state
,
memo
)
if
hasattr
(
y
,
'__setstate__'
):
y
.
__setstate__
(
state
)
else
:
y
.
__dict__
.
update
(
state
)
return
y
d
[
types
.
InstanceType
]
=
_deepcopy_inst
def
_reconstruct
(
x
,
info
,
deep
,
memo
=
None
):
if
isinstance
(
info
,
str
):
return
x
...
...
Lib/dis.py
Dosyayı görüntüle @
65810fee
...
...
@@ -18,8 +18,6 @@ def dis(x=None):
if
x
is
None
:
distb
()
return
if
type
(
x
)
is
types
.
InstanceType
:
x
=
x
.
__class__
if
hasattr
(
x
,
'im_func'
):
x
=
x
.
im_func
if
hasattr
(
x
,
'func_code'
):
...
...
Lib/new.py
Dosyayı görüntüle @
65810fee
...
...
@@ -6,7 +6,6 @@ Objects of most types can now be created by calling the type object.
from
types
import
ClassType
as
classobj
from
types
import
FunctionType
as
function
from
types
import
InstanceType
as
instance
from
types
import
MethodType
as
instancemethod
from
types
import
ModuleType
as
module
...
...
Lib/pickle.py
Dosyayı görüntüle @
65810fee
...
...
@@ -687,46 +687,6 @@ class Pickler:
write
(
SETITEM
)
# else tmp is empty, and we're done
def
save_inst
(
self
,
obj
):
cls
=
obj
.
__class__
memo
=
self
.
memo
write
=
self
.
write
save
=
self
.
save
if
hasattr
(
obj
,
'__getinitargs__'
):
args
=
obj
.
__getinitargs__
()
len
(
args
)
# XXX Assert it's a sequence
_keep_alive
(
args
,
memo
)
else
:
args
=
()
write
(
MARK
)
if
self
.
bin
:
save
(
cls
)
for
arg
in
args
:
save
(
arg
)
write
(
OBJ
)
else
:
for
arg
in
args
:
save
(
arg
)
write
(
INST
+
cls
.
__module__
+
'
\n
'
+
cls
.
__name__
+
'
\n
'
)
self
.
memoize
(
obj
)
try
:
getstate
=
obj
.
__getstate__
except
AttributeError
:
stuff
=
obj
.
__dict__
else
:
stuff
=
getstate
()
_keep_alive
(
stuff
,
memo
)
save
(
stuff
)
write
(
BUILD
)
dispatch
[
InstanceType
]
=
save_inst
def
save_global
(
self
,
obj
,
name
=
None
,
pack
=
struct
.
pack
):
write
=
self
.
write
memo
=
self
.
memo
...
...
Lib/pickletools.py
Dosyayı görüntüle @
65810fee
...
...
@@ -2071,42 +2071,58 @@ highest protocol among opcodes = 0
0: ( MARK
1: l LIST (MARK at 0)
2: p PUT 0
5: ( MARK
6: i INST 'pickletools _Example' (MARK at 5)
28: p PUT 1
31: ( MARK
32: d DICT (MARK at 31)
33: p PUT 2
36: S STRING 'value'
45: p PUT 3
48: I INT 42
52: s SETITEM
53: b BUILD
54: a APPEND
55: g GET 1
58: a APPEND
59: . STOP
5: c GLOBAL 'copy_reg _reconstructor'
30: p PUT 1
33: ( MARK
34: c GLOBAL 'pickletools _Example'
56: p PUT 2
59: c GLOBAL '__builtin__ object'
79: p PUT 3
82: N NONE
83: t TUPLE (MARK at 33)
84: p PUT 4
87: R REDUCE
88: p PUT 5
91: ( MARK
92: d DICT (MARK at 91)
93: p PUT 6
96: S STRING 'value'
105: p PUT 7
108: I INT 42
112: s SETITEM
113: b BUILD
114: a APPEND
115: g GET 5
118: a APPEND
119: . STOP
highest protocol among opcodes = 0
>>> dis(pickle.dumps(x, 1))
0: ] EMPTY_LIST
1: q BINPUT 0
3: ( MARK
4: ( MARK
5: c GLOBAL 'pickletools _Example'
27: q BINPUT 1
29: o OBJ (MARK at 4)
30: q BINPUT 2
32: } EMPTY_DICT
33: q BINPUT 3
35: U SHORT_BINSTRING 'value'
42: q BINPUT 4
44: K BININT1 42
46: s SETITEM
47: b BUILD
48: h BINGET 2
50: e APPENDS (MARK at 3)
51: . STOP
4: c GLOBAL 'copy_reg _reconstructor'
29: q BINPUT 1
31: ( MARK
32: c GLOBAL 'pickletools _Example'
54: q BINPUT 2
56: c GLOBAL '__builtin__ object'
76: q BINPUT 3
78: N NONE
79: t TUPLE (MARK at 31)
80: q BINPUT 4
82: R REDUCE
83: q BINPUT 5
85: } EMPTY_DICT
86: q BINPUT 6
88: U SHORT_BINSTRING 'value'
95: q BINPUT 7
97: K BININT1 42
99: s SETITEM
100: b BUILD
101: h BINGET 5
103: e APPENDS (MARK at 3)
104: . STOP
highest protocol among opcodes = 1
Try "the canonical" recursive-object test.
...
...
Lib/test/output/test_new
Dosyayı görüntüle @
65810fee
test_new
new.module()
new.classobj()
new.instance()
new.instancemethod()
new.function()
new.code()
Lib/test/test_new.py
Dosyayı görüntüle @
65810fee
...
...
@@ -21,22 +21,12 @@ print 'new.classobj()'
C
=
new
.
classobj
(
'Spam'
,
(
Spam
.
Eggs
,),
{
'get_more_yolks'
:
get_more_yolks
})
if
verbose
:
print
C
print
'new.instance()'
c
=
new
.
instance
(
C
,
{
'yolks'
:
3
})
if
verbose
:
print
c
o
=
new
.
instance
(
C
)
verify
(
o
.
__dict__
==
{},
"new __dict__ should be empty"
)
del
o
o
=
new
.
instance
(
C
,
None
)
verify
(
o
.
__dict__
==
{},
"new __dict__ should be empty"
)
del
o
def
break_yolks
(
self
):
self
.
yolks
=
self
.
yolks
-
2
print
'new.instancemethod()'
c
=
C
()
c
.
yolks
=
3
im
=
new
.
instancemethod
(
break_yolks
,
c
,
C
)
if
verbose
:
print
im
...
...
Lib/types.py
Dosyayı görüntüle @
65810fee
...
...
@@ -56,9 +56,7 @@ class _C:
def
_m
(
self
):
pass
ClassType
=
type
(
_C
)
UnboundMethodType
=
type
(
_C
.
_m
)
# Same as MethodType
_x
=
_C
()
InstanceType
=
type
(
_x
)
MethodType
=
type
(
_x
.
_m
)
MethodType
=
type
(
_C
()
.
_m
)
BuiltinFunctionType
=
type
(
len
)
BuiltinMethodType
=
type
([]
.
append
)
# Same as BuiltinFunctionType
...
...
@@ -86,4 +84,4 @@ EllipsisType = type(Ellipsis)
DictProxyType
=
type
(
TypeType
.
__dict__
)
NotImplementedType
=
type
(
NotImplemented
)
del
sys
,
_f
,
_g
,
_C
,
_x
# Not for export
del
sys
,
_f
,
_g
,
_C
# Not for export
Lib/xmlrpclib.py
Dosyayı görüntüle @
65810fee
...
...
@@ -748,7 +748,6 @@ class Marshaller:
else
:
# store instance attributes as a struct (really?)
self
.
dump_struct
(
value
.
__dict__
,
write
)
dispatch
[
InstanceType
]
=
dump_instance
dispatch
[
DateTime
]
=
dump_instance
dispatch
[
Binary
]
=
dump_instance
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment