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
6ec1efb6
Kaydet (Commit)
6ec1efb6
authored
Agu 04, 1995
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
add imp.get_frozen_object()
üst
b7b45627
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
13 deletions
+54
-13
import.c
Python/import.c
+54
-13
No files found.
Python/import.c
Dosyayı görüntüle @
6ec1efb6
...
@@ -411,13 +411,13 @@ find_module(name, path, buf, buflen, p_fp)
...
@@ -411,13 +411,13 @@ find_module(name, path, buf, buflen, p_fp)
{
{
int
i
,
npath
,
len
,
namelen
;
int
i
,
npath
,
len
,
namelen
;
struct
filedescr
*
fdp
;
struct
filedescr
*
fdp
;
FILE
*
fp
;
FILE
*
fp
=
NULL
;
if
(
path
==
NULL
)
if
(
path
==
NULL
)
path
=
sysget
(
"path"
);
path
=
sysget
(
"path"
);
if
(
path
==
NULL
||
!
is_listobject
(
path
))
{
if
(
path
==
NULL
||
!
is_listobject
(
path
))
{
err_setstr
(
ImportError
,
err_setstr
(
ImportError
,
"module search path must be
list of directory names"
);
"sys.path must be a
list of directory names"
);
return
NULL
;
return
NULL
;
}
}
npath
=
getlistsize
(
path
);
npath
=
getlistsize
(
path
);
...
@@ -528,7 +528,7 @@ init_builtin(name)
...
@@ -528,7 +528,7 @@ init_builtin(name)
if
(
strcmp
(
name
,
inittab
[
i
].
name
)
==
0
)
{
if
(
strcmp
(
name
,
inittab
[
i
].
name
)
==
0
)
{
if
(
inittab
[
i
].
initfunc
==
NULL
)
{
if
(
inittab
[
i
].
initfunc
==
NULL
)
{
err_setstr
(
ImportError
,
err_setstr
(
ImportError
,
"
c
annot re-init internal module"
);
"
C
annot re-init internal module"
);
return
-
1
;
return
-
1
;
}
}
if
(
verbose
)
if
(
verbose
)
...
@@ -544,9 +544,7 @@ init_builtin(name)
...
@@ -544,9 +544,7 @@ init_builtin(name)
}
}
/* Initialize a frozen module.
/* Frozen modules */
Return 1 for succes, 0 if the module is not found, and -1 with
an exception set if the initialization failed. */
extern
struct
frozen
{
extern
struct
frozen
{
char
*
name
;
char
*
name
;
...
@@ -554,21 +552,50 @@ extern struct frozen {
...
@@ -554,21 +552,50 @@ extern struct frozen {
int
size
;
int
size
;
}
frozen_modules
[];
}
frozen_modules
[];
/* This function is also used from frozenmain.c */
static
struct
frozen
*
find_frozen
(
name
)
int
init_frozen
(
name
)
char
*
name
;
char
*
name
;
{
{
struct
frozen
*
p
;
struct
frozen
*
p
;
object
*
co
;
object
*
co
;
object
*
m
;
for
(
p
=
frozen_modules
;
;
p
++
)
{
for
(
p
=
frozen_modules
;
;
p
++
)
{
if
(
p
->
name
==
NULL
)
if
(
p
->
name
==
NULL
)
return
0
;
return
NULL
;
if
(
strcmp
(
p
->
name
,
name
)
==
0
)
if
(
strcmp
(
p
->
name
,
name
)
==
0
)
break
;
break
;
}
}
return
p
;
}
static
object
*
get_frozen_object
(
name
)
char
*
name
;
{
struct
frozen
*
p
=
find_frozen
(
name
);
if
(
p
==
NULL
)
{
err_setstr
(
ImportError
,
"No such frozen object"
);
return
NULL
;
}
return
rds_object
(
p
->
code
,
p
->
size
);
}
/* Initialize a frozen module.
Return 1 for succes, 0 if the module is not found, and -1 with
an exception set if the initialization failed.
This function is also used from frozenmain.c */
int
init_frozen
(
name
)
char
*
name
;
{
struct
frozen
*
p
=
find_frozen
(
name
);
object
*
co
;
object
*
m
;
if
(
p
==
NULL
)
return
0
;
if
(
verbose
)
if
(
verbose
)
fprintf
(
stderr
,
"import %s # frozen
\n
"
,
name
);
fprintf
(
stderr
,
"import %s # frozen
\n
"
,
name
);
co
=
rds_object
(
p
->
code
,
p
->
size
);
co
=
rds_object
(
p
->
code
,
p
->
size
);
...
@@ -576,7 +603,7 @@ init_frozen(name)
...
@@ -576,7 +603,7 @@ init_frozen(name)
return
-
1
;
return
-
1
;
if
(
!
is_codeobject
(
co
))
{
if
(
!
is_codeobject
(
co
))
{
DECREF
(
co
);
DECREF
(
co
);
err_setstr
(
System
Error
,
"frozen object is not a code object"
);
err_setstr
(
Type
Error
,
"frozen object is not a code object"
);
return
-
1
;
return
-
1
;
}
}
m
=
exec_code_module
(
name
,
co
);
m
=
exec_code_module
(
name
,
co
);
...
@@ -785,6 +812,19 @@ imp_init_frozen(self, args)
...
@@ -785,6 +812,19 @@ imp_init_frozen(self, args)
return
m
;
return
m
;
}
}
static
object
*
imp_get_frozen_object
(
self
,
args
)
object
*
self
;
object
*
args
;
{
char
*
name
;
int
ret
;
object
*
m
;
if
(
!
newgetargs
(
args
,
"s"
,
&
name
))
return
NULL
;
return
get_frozen_object
(
name
);
}
static
object
*
static
object
*
imp_is_builtin
(
self
,
args
)
imp_is_builtin
(
self
,
args
)
object
*
self
;
object
*
self
;
...
@@ -928,6 +968,7 @@ imp_new_module(self, args)
...
@@ -928,6 +968,7 @@ imp_new_module(self, args)
}
}
static
struct
methodlist
imp_methods
[]
=
{
static
struct
methodlist
imp_methods
[]
=
{
{
"get_frozen_object"
,
imp_get_frozen_object
,
1
},
{
"get_magic"
,
imp_get_magic
,
1
},
{
"get_magic"
,
imp_get_magic
,
1
},
{
"get_suffixes"
,
imp_get_suffixes
,
1
},
{
"get_suffixes"
,
imp_get_suffixes
,
1
},
{
"find_module"
,
imp_find_module
,
1
},
{
"find_module"
,
imp_find_module
,
1
},
...
...
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