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
7e95befe
Kaydet (Commit)
7e95befe
authored
Agu 26, 2007
tarafından
Neal Norwitz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Use unicode and stop supporting str8
üst
fe537135
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
15 deletions
+9
-15
test_funcattrs.py
Lib/test/test_funcattrs.py
+2
-2
funcobject.c
Objects/funcobject.c
+7
-13
No files found.
Lib/test/test_funcattrs.py
Dosyayı görüntüle @
7e95befe
...
@@ -258,8 +258,8 @@ def test_func_globals():
...
@@ -258,8 +258,8 @@ def test_func_globals():
def
test_func_name
():
def
test_func_name
():
def
f
():
pass
def
f
():
pass
verify
(
f
.
__name__
==
"f"
)
verify
(
f
.
__name__
==
"f"
)
f
.
__name__
=
str8
(
"g"
)
f
.
__name__
=
"g"
verify
(
f
.
__name__
==
str8
(
"g"
)
)
verify
(
f
.
__name__
==
"g"
)
cantset
(
f
,
"__globals__"
,
1
)
cantset
(
f
,
"__globals__"
,
1
)
cantset
(
f
,
"__name__"
,
1
)
cantset
(
f
,
"__name__"
,
1
)
# test that you can access func.__name__ in restricted mode
# test that you can access func.__name__ in restricted mode
...
...
Objects/funcobject.c
Dosyayı görüntüle @
7e95befe
...
@@ -29,7 +29,7 @@ PyFunction_New(PyObject *code, PyObject *globals)
...
@@ -29,7 +29,7 @@ PyFunction_New(PyObject *code, PyObject *globals)
consts
=
((
PyCodeObject
*
)
code
)
->
co_consts
;
consts
=
((
PyCodeObject
*
)
code
)
->
co_consts
;
if
(
PyTuple_Size
(
consts
)
>=
1
)
{
if
(
PyTuple_Size
(
consts
)
>=
1
)
{
doc
=
PyTuple_GetItem
(
consts
,
0
);
doc
=
PyTuple_GetItem
(
consts
,
0
);
if
(
!
Py
String_Check
(
doc
)
&&
!
Py
Unicode_Check
(
doc
))
if
(
!
PyUnicode_Check
(
doc
))
doc
=
Py_None
;
doc
=
Py_None
;
}
}
else
else
...
@@ -44,7 +44,7 @@ PyFunction_New(PyObject *code, PyObject *globals)
...
@@ -44,7 +44,7 @@ PyFunction_New(PyObject *code, PyObject *globals)
Otherwise, use None.
Otherwise, use None.
*/
*/
if
(
!
__name__
)
{
if
(
!
__name__
)
{
__name__
=
Py
String
_InternFromString
(
"__name__"
);
__name__
=
Py
Unicode
_InternFromString
(
"__name__"
);
if
(
!
__name__
)
{
if
(
!
__name__
)
{
Py_DECREF
(
op
);
Py_DECREF
(
op
);
return
NULL
;
return
NULL
;
...
@@ -297,7 +297,7 @@ func_set_code(PyFunctionObject *op, PyObject *value)
...
@@ -297,7 +297,7 @@ func_set_code(PyFunctionObject *op, PyObject *value)
PyErr_Format
(
PyExc_ValueError
,
PyErr_Format
(
PyExc_ValueError
,
"%s() requires a code object with %zd free vars,"
"%s() requires a code object with %zd free vars,"
" not %zd"
,
" not %zd"
,
Py
String
_AsString
(
op
->
func_name
),
Py
Unicode
_AsString
(
op
->
func_name
),
nclosure
,
nfree
);
nclosure
,
nfree
);
return
-
1
;
return
-
1
;
}
}
...
@@ -322,7 +322,7 @@ func_set_name(PyFunctionObject *op, PyObject *value)
...
@@ -322,7 +322,7 @@ func_set_name(PyFunctionObject *op, PyObject *value)
/* Not legal to del f.func_name or to set it to anything
/* Not legal to del f.func_name or to set it to anything
* other than a string object. */
* other than a string object. */
if
(
value
==
NULL
||
(
!
PyString_Check
(
value
)
&&
!
PyUnicode_Check
(
value
)
))
{
if
(
value
==
NULL
||
!
PyUnicode_Check
(
value
))
{
PyErr_SetString
(
PyExc_TypeError
,
PyErr_SetString
(
PyExc_TypeError
,
"__name__ must be set to a string object"
);
"__name__ must be set to a string object"
);
return
-
1
;
return
-
1
;
...
@@ -482,12 +482,7 @@ func_new(PyTypeObject* type, PyObject* args, PyObject* kw)
...
@@ -482,12 +482,7 @@ func_new(PyTypeObject* type, PyObject* args, PyObject* kw)
&
PyDict_Type
,
&
globals
,
&
PyDict_Type
,
&
globals
,
&
name
,
&
defaults
,
&
closure
))
&
name
,
&
defaults
,
&
closure
))
return
NULL
;
return
NULL
;
if
(
PyUnicode_Check
(
name
))
{
if
(
name
!=
Py_None
&&
!
PyUnicode_Check
(
name
))
{
name
=
_PyUnicode_AsDefaultEncodedString
(
name
,
NULL
);
if
(
name
==
NULL
)
return
NULL
;
}
if
(
name
!=
Py_None
&&
!
PyString_Check
(
name
))
{
PyErr_SetString
(
PyExc_TypeError
,
PyErr_SetString
(
PyExc_TypeError
,
"arg 3 (name) must be None or string"
);
"arg 3 (name) must be None or string"
);
return
NULL
;
return
NULL
;
...
@@ -573,9 +568,8 @@ func_dealloc(PyFunctionObject *op)
...
@@ -573,9 +568,8 @@ func_dealloc(PyFunctionObject *op)
static
PyObject
*
static
PyObject
*
func_repr
(
PyFunctionObject
*
op
)
func_repr
(
PyFunctionObject
*
op
)
{
{
return
PyUnicode_FromFormat
(
"<function %s at %p>"
,
return
PyUnicode_FromFormat
(
"<function %U at %p>"
,
PyString_AsString
(
op
->
func_name
),
op
->
func_name
,
op
);
op
);
}
}
static
int
static
int
...
...
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