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
f21ad923
Kaydet (Commit)
f21ad923
authored
Mar 26, 2011
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
check possible recursive _as_parameter_ to prevent segfault (closes #1838)
üst
41347fe0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
2 deletions
+43
-2
test_as_parameter.py
Lib/ctypes/test/test_as_parameter.py
+12
-0
refactor.py
Lib/lib2to3/refactor.py
+1
-1
test_refactor.py
Lib/lib2to3/tests/test_refactor.py
+17
-0
NEWS
Misc/NEWS
+3
-0
_ctypes.c
Modules/_ctypes/_ctypes.c
+10
-1
No files found.
Lib/ctypes/test/test_as_parameter.py
Dosyayı görüntüle @
f21ad923
...
@@ -187,6 +187,18 @@ class BasicWrapTestCase(unittest.TestCase):
...
@@ -187,6 +187,18 @@ class BasicWrapTestCase(unittest.TestCase):
self
.
assertEqual
((
s8i
.
a
,
s8i
.
b
,
s8i
.
c
,
s8i
.
d
,
s8i
.
e
,
s8i
.
f
,
s8i
.
g
,
s8i
.
h
),
self
.
assertEqual
((
s8i
.
a
,
s8i
.
b
,
s8i
.
c
,
s8i
.
d
,
s8i
.
e
,
s8i
.
f
,
s8i
.
g
,
s8i
.
h
),
(
9
*
2
,
8
*
3
,
7
*
4
,
6
*
5
,
5
*
6
,
4
*
7
,
3
*
8
,
2
*
9
))
(
9
*
2
,
8
*
3
,
7
*
4
,
6
*
5
,
5
*
6
,
4
*
7
,
3
*
8
,
2
*
9
))
def
test_recursive_as_param
(
self
):
from
ctypes
import
c_int
class
A
(
object
):
pass
a
=
A
()
a
.
_as_parameter_
=
a
with
self
.
assertRaises
(
RuntimeError
):
c_int
.
from_param
(
a
)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class
AsParamWrapper
(
object
):
class
AsParamWrapper
(
object
):
...
...
Lib/lib2to3/refactor.py
Dosyayı görüntüle @
f21ad923
...
@@ -500,7 +500,7 @@ class RefactoringTool(object):
...
@@ -500,7 +500,7 @@ class RefactoringTool(object):
node
=
new
node
=
new
def
processed_file
(
self
,
new_text
,
filename
,
old_text
=
None
,
write
=
False
,
def
processed_file
(
self
,
new_text
,
filename
,
old_text
=
None
,
write
=
False
,
encoding
=
None
):
encoding
=
None
,
newlines
=
None
):
"""
"""
Called when a file has been refactored, and there are changes.
Called when a file has been refactored, and there are changes.
"""
"""
...
...
Lib/lib2to3/tests/test_refactor.py
Dosyayı görüntüle @
f21ad923
...
@@ -231,6 +231,23 @@ from __future__ import print_function"""
...
@@ -231,6 +231,23 @@ from __future__ import print_function"""
os
.
path
.
join
(
"a_dir"
,
"stuff.py"
)]
os
.
path
.
join
(
"a_dir"
,
"stuff.py"
)]
check
(
tree
,
tree
)
check
(
tree
,
tree
)
def
test_preserve_file_newlines
(
self
):
rt
=
self
.
rt
(
fixers
=
_2TO3_FIXERS
)
for
nl
in
(
"
\r\n
"
,
"
\n
"
):
data
=
"print y
%
s
%
syes
%
sok
%
s"
%
((
nl
,)
*
4
)
handle
,
tmp
=
tempfile
.
mkstemp
()
os
.
close
(
handle
)
try
:
with
open
(
tmp
,
"w"
)
as
fp
:
fp
.
write
(
data
)
rt
.
refactor_file
(
tmp
)
with
open
(
tmp
,
"r"
)
as
fp
:
contents
=
fp
.
read
()
finally
:
os
.
unlink
(
tmp
)
for
line
in
contents
.
splitlines
(
True
):
self
.
assertTrue
(
line
.
endswith
(
nl
))
def
test_file_encoding
(
self
):
def
test_file_encoding
(
self
):
fn
=
os
.
path
.
join
(
TEST_DATA_DIR
,
"different_encoding.py"
)
fn
=
os
.
path
.
join
(
TEST_DATA_DIR
,
"different_encoding.py"
)
self
.
check_file_refactoring
(
fn
)
self
.
check_file_refactoring
(
fn
)
...
...
Misc/NEWS
Dosyayı görüntüle @
f21ad923
...
@@ -245,6 +245,9 @@ Library
...
@@ -245,6 +245,9 @@ Library
Extension
Modules
Extension
Modules
-----------------
-----------------
-
Issue
#
1838
:
Prevent
segfault
in
ctypes
,
when
_as_parameter_
on
a
class
is
set
to
an
instance
of
the
class
.
-
Issue
#
678250
:
Make
mmap
flush
a
noop
on
ACCESS_READ
and
ACCESS_COPY
.
-
Issue
#
678250
:
Make
mmap
flush
a
noop
on
ACCESS_READ
and
ACCESS_COPY
.
Build
Build
...
...
Modules/_ctypes/_ctypes.c
Dosyayı görüntüle @
f21ad923
...
@@ -2065,10 +2065,14 @@ PyCSimpleType_from_param(PyObject *type, PyObject *value)
...
@@ -2065,10 +2065,14 @@ PyCSimpleType_from_param(PyObject *type, PyObject *value)
PyCArgObject
*
parg
;
PyCArgObject
*
parg
;
struct
fielddesc
*
fd
;
struct
fielddesc
*
fd
;
PyObject
*
as_parameter
;
PyObject
*
as_parameter
;
int
res
;
/* If the value is already an instance of the requested type,
/* If the value is already an instance of the requested type,
we can use it as is */
we can use it as is */
if
(
1
==
PyObject_IsInstance
(
value
,
type
))
{
res
=
PyObject_IsInstance
(
value
,
type
);
if
(
res
==
-
1
)
return
NULL
;
if
(
res
)
{
Py_INCREF
(
value
);
Py_INCREF
(
value
);
return
value
;
return
value
;
}
}
...
@@ -2097,7 +2101,12 @@ PyCSimpleType_from_param(PyObject *type, PyObject *value)
...
@@ -2097,7 +2101,12 @@ PyCSimpleType_from_param(PyObject *type, PyObject *value)
as_parameter
=
PyObject_GetAttrString
(
value
,
"_as_parameter_"
);
as_parameter
=
PyObject_GetAttrString
(
value
,
"_as_parameter_"
);
if
(
as_parameter
)
{
if
(
as_parameter
)
{
if
(
Py_EnterRecursiveCall
(
"while processing _as_parameter_"
))
{
Py_DECREF
(
as_parameter
);
return
NULL
;
}
value
=
PyCSimpleType_from_param
(
type
,
as_parameter
);
value
=
PyCSimpleType_from_param
(
type
,
as_parameter
);
Py_LeaveRecursiveCall
();
Py_DECREF
(
as_parameter
);
Py_DECREF
(
as_parameter
);
return
value
;
return
value
;
}
}
...
...
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