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
5562d9dc
Kaydet (Commit)
5562d9dc
authored
Tem 28, 2012
tarafından
Richard Oudkerk
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #1692335: Move initial args assignment to BaseException.__new__
to help pickling of naive subclasses.
üst
e4c0799d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
2 deletions
+28
-2
test_exceptions.py
Lib/test/test_exceptions.py
+15
-1
NEWS
Misc/NEWS
+3
-0
exceptions.c
Objects/exceptions.c
+10
-1
No files found.
Lib/test/test_exceptions.py
Dosyayı görüntüle @
5562d9dc
...
@@ -10,6 +10,15 @@ import errno
...
@@ -10,6 +10,15 @@ import errno
from
test.support
import
(
TESTFN
,
unlink
,
run_unittest
,
captured_output
,
from
test.support
import
(
TESTFN
,
unlink
,
run_unittest
,
captured_output
,
gc_collect
,
cpython_only
,
no_tracing
)
gc_collect
,
cpython_only
,
no_tracing
)
class
NaiveException
(
Exception
):
def
__init__
(
self
,
x
):
self
.
x
=
x
class
SlottedNaiveException
(
Exception
):
__slots__
=
(
'x'
,)
def
__init__
(
self
,
x
):
self
.
x
=
x
# XXX This is not really enough, each *operation* should be tested!
# XXX This is not really enough, each *operation* should be tested!
class
ExceptionTests
(
unittest
.
TestCase
):
class
ExceptionTests
(
unittest
.
TestCase
):
...
@@ -296,6 +305,10 @@ class ExceptionTests(unittest.TestCase):
...
@@ -296,6 +305,10 @@ class ExceptionTests(unittest.TestCase):
{
'args'
:
(
'
\u3042
'
,
0
,
1
,
'ouch'
),
{
'args'
:
(
'
\u3042
'
,
0
,
1
,
'ouch'
),
'object'
:
'
\u3042
'
,
'reason'
:
'ouch'
,
'object'
:
'
\u3042
'
,
'reason'
:
'ouch'
,
'start'
:
0
,
'end'
:
1
}),
'start'
:
0
,
'end'
:
1
}),
(
NaiveException
,
(
'foo'
,),
{
'args'
:
(
'foo'
,),
'x'
:
'foo'
}),
(
SlottedNaiveException
,
(
'foo'
,),
{
'args'
:
(
'foo'
,),
'x'
:
'foo'
}),
]
]
try
:
try
:
# More tests are in test_WindowsError
# More tests are in test_WindowsError
...
@@ -316,7 +329,8 @@ class ExceptionTests(unittest.TestCase):
...
@@ -316,7 +329,8 @@ class ExceptionTests(unittest.TestCase):
raise
raise
else
:
else
:
# Verify module name
# Verify module name
self
.
assertEqual
(
type
(
e
)
.
__module__
,
'builtins'
)
if
not
type
(
e
)
.
__name__
.
endswith
(
'NaiveException'
):
self
.
assertEqual
(
type
(
e
)
.
__module__
,
'builtins'
)
# Verify no ref leaks in Exc_str()
# Verify no ref leaks in Exc_str()
s
=
str
(
e
)
s
=
str
(
e
)
for
checkArgName
in
expected
:
for
checkArgName
in
expected
:
...
...
Misc/NEWS
Dosyayı görüntüle @
5562d9dc
...
@@ -10,6 +10,9 @@ What's New in Python 3.3.0 Beta 2?
...
@@ -10,6 +10,9 @@ What's New in Python 3.3.0 Beta 2?
Core and Builtins
Core and Builtins
-----------------
-----------------
- Issue #1692335: Move initial args assignment to
BaseException.__new__ to help pickling of naive subclasses.
- Issue #12834: Fix PyBuffer_ToContiguous() for non-contiguous arrays.
- Issue #12834: Fix PyBuffer_ToContiguous() for non-contiguous arrays.
- Issue #15456: Fix code __sizeof__ after #12399 change.
- Issue #15456: Fix code __sizeof__ after #12399 change.
...
...
Objects/exceptions.c
Dosyayı görüntüle @
5562d9dc
...
@@ -44,6 +44,12 @@ BaseException_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
...
@@ -44,6 +44,12 @@ BaseException_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self
->
traceback
=
self
->
cause
=
self
->
context
=
NULL
;
self
->
traceback
=
self
->
cause
=
self
->
context
=
NULL
;
self
->
suppress_context
=
0
;
self
->
suppress_context
=
0
;
if
(
args
)
{
self
->
args
=
args
;
Py_INCREF
(
args
);
return
(
PyObject
*
)
self
;
}
self
->
args
=
PyTuple_New
(
0
);
self
->
args
=
PyTuple_New
(
0
);
if
(
!
self
->
args
)
{
if
(
!
self
->
args
)
{
Py_DECREF
(
self
);
Py_DECREF
(
self
);
...
@@ -56,12 +62,15 @@ BaseException_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
...
@@ -56,12 +62,15 @@ BaseException_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static
int
static
int
BaseException_init
(
PyBaseExceptionObject
*
self
,
PyObject
*
args
,
PyObject
*
kwds
)
BaseException_init
(
PyBaseExceptionObject
*
self
,
PyObject
*
args
,
PyObject
*
kwds
)
{
{
PyObject
*
tmp
;
if
(
!
_PyArg_NoKeywords
(
Py_TYPE
(
self
)
->
tp_name
,
kwds
))
if
(
!
_PyArg_NoKeywords
(
Py_TYPE
(
self
)
->
tp_name
,
kwds
))
return
-
1
;
return
-
1
;
Py_XDECREF
(
self
->
args
)
;
tmp
=
self
->
args
;
self
->
args
=
args
;
self
->
args
=
args
;
Py_INCREF
(
self
->
args
);
Py_INCREF
(
self
->
args
);
Py_XDECREF
(
tmp
);
return
0
;
return
0
;
}
}
...
...
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