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
7f9fa97c
Kaydet (Commit)
7f9fa97c
authored
Ock 20, 1995
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
fix import related leaks
üst
855d0b36
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
17 deletions
+23
-17
bltinmodule.c
Python/bltinmodule.c
+1
-5
import.c
Python/import.c
+22
-12
No files found.
Python/bltinmodule.c
Dosyayı görüntüle @
7f9fa97c
...
@@ -47,14 +47,10 @@ builtin___import__(self, args)
...
@@ -47,14 +47,10 @@ builtin___import__(self, args)
object
*
args
;
object
*
args
;
{
{
char
*
name
;
char
*
name
;
object
*
m
;
if
(
!
newgetargs
(
args
,
"s:__import__"
,
&
name
))
if
(
!
newgetargs
(
args
,
"s:__import__"
,
&
name
))
return
NULL
;
return
NULL
;
m
=
import_module
(
name
);
return
import_module
(
name
);
XINCREF
(
m
);
return
m
;
}
}
...
...
Python/import.c
Dosyayı görüntüle @
7f9fa97c
...
@@ -110,8 +110,8 @@ get_modules()
...
@@ -110,8 +110,8 @@ get_modules()
/* Get the module object corresponding to a module name.
/* Get the module object corresponding to a module name.
First check the modules dictionary if there's one there,
First check the modules dictionary if there's one there,
if not, create a new one and insert in in the modules dictionary.
if not, create a new one and insert in in the modules dictionary.
Because the former action is most common,
this does not return a
Because the former action is most common,
THIS DOES NOT RETURN A
'
new' reference
! */
'
NEW' REFERENCE
! */
object
*
object
*
add_module
(
name
)
add_module
(
name
)
...
@@ -135,7 +135,8 @@ add_module(name)
...
@@ -135,7 +135,8 @@ add_module(name)
}
}
/* Execute a code object in a module and return its module object */
/* Execute a code object in a module and return the module object
WITH INCREMENTED REFERENCE COUNT */
static
object
*
static
object
*
exec_code_module
(
name
,
co
)
exec_code_module
(
name
,
co
)
...
@@ -247,7 +248,7 @@ read_compiled_module(fp)
...
@@ -247,7 +248,7 @@ read_compiled_module(fp)
/* Load a module from a compiled file, execute it, and return its
/* Load a module from a compiled file, execute it, and return its
module object */
module object
WITH INCREMENTED REFERENCE COUNT
*/
static
object
*
static
object
*
load_compiled_module
(
name
,
cpathname
,
fp
)
load_compiled_module
(
name
,
cpathname
,
fp
)
...
@@ -344,8 +345,8 @@ write_compiled_module(co, cpathname, mtime)
...
@@ -344,8 +345,8 @@ write_compiled_module(co, cpathname, mtime)
/* Load a source module from a given file and return its module
/* Load a source module from a given file and return its module
object
. If there's a matching byte-compiled file, use that
object
WITH INCREMENTED REFERENCE COUNT. If there's a matching
instead. */
byte-compiled file, use that
instead. */
static
object
*
static
object
*
load_source_module
(
name
,
pathname
,
fp
)
load_source_module
(
name
,
pathname
,
fp
)
...
@@ -452,7 +453,7 @@ find_module(name, path, buf, buflen, p_fp)
...
@@ -452,7 +453,7 @@ find_module(name, path, buf, buflen, p_fp)
/* Load an external module using the default search path and return
/* Load an external module using the default search path and return
its module object */
its module object
WITH INCREMENTED REFERENCE COUNT
*/
static
object
*
static
object
*
load_module
(
name
)
load_module
(
name
)
...
@@ -461,7 +462,7 @@ load_module(name)
...
@@ -461,7 +462,7 @@ load_module(name)
char
buf
[
MAXPATHLEN
+
1
];
char
buf
[
MAXPATHLEN
+
1
];
struct
filedescr
*
fdp
;
struct
filedescr
*
fdp
;
FILE
*
fp
=
NULL
;
FILE
*
fp
=
NULL
;
object
*
m
=
NULL
;
object
*
m
;
fdp
=
find_module
(
name
,
(
object
*
)
NULL
,
buf
,
MAXPATHLEN
+
1
,
&
fp
);
fdp
=
find_module
(
name
,
(
object
*
)
NULL
,
buf
,
MAXPATHLEN
+
1
,
&
fp
);
if
(
fdp
==
NULL
)
if
(
fdp
==
NULL
)
...
@@ -484,6 +485,7 @@ load_module(name)
...
@@ -484,6 +485,7 @@ load_module(name)
default
:
default
:
err_setstr
(
SystemError
,
err_setstr
(
SystemError
,
"find_module returned unexpected result"
);
"find_module returned unexpected result"
);
m
=
NULL
;
}
}
fclose
(
fp
);
fclose
(
fp
);
...
@@ -556,12 +558,15 @@ init_frozen(name)
...
@@ -556,12 +558,15 @@ init_frozen(name)
}
}
m
=
exec_code_module
(
name
,
(
codeobject
*
)
co
);
m
=
exec_code_module
(
name
,
(
codeobject
*
)
co
);
DECREF
(
co
);
DECREF
(
co
);
return
m
==
NULL
?
-
1
:
1
;
if
(
m
==
NULL
)
return
-
1
;
DECREF
(
m
);
return
1
;
}
}
/* Import a module, either built-in, frozen, or external, and return
/* Import a module, either built-in, frozen, or external, and return
its module object */
its module object
WITH INCREMENTED REFERENCE COUNT
*/
object
*
object
*
import_module
(
name
)
import_module
(
name
)
...
@@ -569,7 +574,10 @@ import_module(name)
...
@@ -569,7 +574,10 @@ import_module(name)
{
{
object
*
m
;
object
*
m
;
if
((
m
=
dictlookup
(
import_modules
,
name
))
==
NULL
)
{
if
((
m
=
dictlookup
(
import_modules
,
name
))
!=
NULL
)
{
INCREF
(
m
);
}
else
{
int
i
;
int
i
;
if
((
i
=
init_builtin
(
name
))
||
(
i
=
init_frozen
(
name
)))
{
if
((
i
=
init_builtin
(
name
))
||
(
i
=
init_frozen
(
name
)))
{
if
(
i
<
0
)
if
(
i
<
0
)
...
@@ -579,6 +587,8 @@ import_module(name)
...
@@ -579,6 +587,8 @@ import_module(name)
err_setstr
(
SystemError
,
err_setstr
(
SystemError
,
"built-in module not initialized properly"
);
"built-in module not initialized properly"
);
}
}
else
INCREF
(
m
);
}
}
else
else
m
=
load_module
(
name
);
m
=
load_module
(
name
);
...
@@ -613,10 +623,10 @@ reload_module(m)
...
@@ -613,10 +623,10 @@ reload_module(m)
if
((
i
=
init_builtin
(
name
))
||
(
i
=
init_frozen
(
name
)))
{
if
((
i
=
init_builtin
(
name
))
||
(
i
=
init_frozen
(
name
)))
{
if
(
i
<
0
)
if
(
i
<
0
)
return
NULL
;
return
NULL
;
INCREF
(
m
);
}
}
else
else
m
=
load_module
(
name
);
m
=
load_module
(
name
);
XINCREF
(
m
);
return
m
;
return
m
;
}
}
...
...
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