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
37075c5a
Kaydet (Commit)
37075c5a
authored
Şub 27, 2007
tarafından
Jeremy Hylton
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix long-standing bug in name mangling for package imports
Reported by Mike Verdone.
üst
c6a1ef3f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
2 deletions
+25
-2
test_compile.py
Lib/test/test_compile.py
+13
-0
compile.c
Python/compile.c
+12
-2
No files found.
Lib/test/test_compile.py
Dosyayı görüntüle @
37075c5a
...
@@ -394,6 +394,19 @@ if 1:
...
@@ -394,6 +394,19 @@ if 1:
del
d
[
...
,
...
]
del
d
[
...
,
...
]
self
.
assertEqual
((
Ellipsis
,
Ellipsis
)
in
d
,
False
)
self
.
assertEqual
((
Ellipsis
,
Ellipsis
)
in
d
,
False
)
def
test_mangling
(
self
):
class
A
:
def
f
():
__mangled
=
1
__not_mangled__
=
2
import
__mangled_mod
import
__package__.module
self
.
assert_
(
"_A__mangled"
in
A
.
f
.
func_code
.
co_varnames
)
self
.
assert_
(
"__not_mangled__"
in
A
.
f
.
func_code
.
co_varnames
)
self
.
assert_
(
"_A__mangled_mod"
in
A
.
f
.
func_code
.
co_varnames
)
self
.
assert_
(
"__package__"
in
A
.
f
.
func_code
.
co_varnames
)
def
test_main
():
def
test_main
():
test_support
.
run_unittest
(
TestSpecifics
)
test_support
.
run_unittest
(
TestSpecifics
)
...
...
Python/compile.c
Dosyayı görüntüle @
37075c5a
...
@@ -194,7 +194,17 @@ _Py_Mangle(PyObject *privateobj, PyObject *ident)
...
@@ -194,7 +194,17 @@ _Py_Mangle(PyObject *privateobj, PyObject *ident)
}
}
p
=
PyString_AsString
(
privateobj
);
p
=
PyString_AsString
(
privateobj
);
nlen
=
strlen
(
name
);
nlen
=
strlen
(
name
);
if
(
name
[
nlen
-
1
]
==
'_'
&&
name
[
nlen
-
2
]
==
'_'
)
{
/* Don't mangle __id__ or names with dots.
The only time a name with a dot can occur is when
we are compiling an import statement that has a
package name.
TODO(jhylton): Decide whether we want to support
mangling of the module name, e.g. __M.X.
*/
if
((
name
[
nlen
-
1
]
==
'_'
&&
name
[
nlen
-
2
]
==
'_'
)
||
strchr
(
name
,
'.'
))
{
Py_INCREF
(
ident
);
Py_INCREF
(
ident
);
return
ident
;
/* Don't mangle __whatever__ */
return
ident
;
/* Don't mangle __whatever__ */
}
}
...
@@ -2243,7 +2253,7 @@ compiler_nameop(struct compiler *c, identifier name, expr_context_ty ctx)
...
@@ -2243,7 +2253,7 @@ compiler_nameop(struct compiler *c, identifier name, expr_context_ty ctx)
return
compiler_error
(
c
,
"can not assign to __debug__"
);
return
compiler_error
(
c
,
"can not assign to __debug__"
);
}
}
mangled
=
_Py_Mangle
(
c
->
u
->
u_private
,
name
);
mangled
=
_Py_Mangle
(
c
->
u
->
u_private
,
name
);
if
(
!
mangled
)
if
(
!
mangled
)
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