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
6262cc79
Kaydet (Commit)
6262cc79
authored
May 09, 2007
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
More uniform approach to getting (UTF8) bytes out of a string.
üst
33f3124f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
30 deletions
+3
-30
import.c
Python/import.c
+3
-30
No files found.
Python/import.c
Dosyayı görüntüle @
6262cc79
...
@@ -1252,40 +1252,20 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
...
@@ -1252,40 +1252,20 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
npath
=
PyList_Size
(
path
);
npath
=
PyList_Size
(
path
);
namelen
=
strlen
(
name
);
namelen
=
strlen
(
name
);
for
(
i
=
0
;
i
<
npath
;
i
++
)
{
for
(
i
=
0
;
i
<
npath
;
i
++
)
{
PyObject
*
copy
=
NULL
;
PyObject
*
v
=
PyList_GetItem
(
path
,
i
);
PyObject
*
v
=
PyList_GetItem
(
path
,
i
);
PyObject
*
origv
=
v
;
PyObject
*
origv
=
v
;
char
*
base
;
c
onst
c
har
*
base
;
Py_ssize_t
size
;
Py_ssize_t
size
;
if
(
!
v
)
if
(
!
v
)
return
NULL
;
return
NULL
;
if
(
PyUnicode_Check
(
v
))
{
if
(
PyObject_AsCharBuffer
(
v
,
&
base
,
&
size
)
<
0
)
copy
=
PyUnicode_Encode
(
PyUnicode_AS_UNICODE
(
v
),
return
NULL
;
PyUnicode_GET_SIZE
(
v
),
Py_FileSystemDefaultEncoding
,
NULL
);
if
(
copy
==
NULL
)
return
NULL
;
v
=
copy
;
}
if
(
PyString_Check
(
v
))
{
base
=
PyString_AS_STRING
(
v
);
size
=
PyString_GET_SIZE
(
v
);
}
else
if
(
PyBytes_Check
(
v
))
{
base
=
PyBytes_AS_STRING
(
v
);
size
=
PyBytes_GET_SIZE
(
v
);
}
else
{
Py_XDECREF
(
copy
);
continue
;
}
len
=
size
;
len
=
size
;
if
(
len
+
2
+
namelen
+
MAXSUFFIXSIZE
>=
buflen
)
{
if
(
len
+
2
+
namelen
+
MAXSUFFIXSIZE
>=
buflen
)
{
Py_XDECREF
(
copy
);
continue
;
/* Too long */
continue
;
/* Too long */
}
}
strcpy
(
buf
,
base
);
strcpy
(
buf
,
base
);
if
(
strlen
(
buf
)
!=
len
)
{
if
(
strlen
(
buf
)
!=
len
)
{
Py_XDECREF
(
copy
);
continue
;
/* v contains '\0' */
continue
;
/* v contains '\0' */
}
}
...
@@ -1296,7 +1276,6 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
...
@@ -1296,7 +1276,6 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
importer
=
get_path_importer
(
path_importer_cache
,
importer
=
get_path_importer
(
path_importer_cache
,
path_hooks
,
origv
);
path_hooks
,
origv
);
if
(
importer
==
NULL
)
{
if
(
importer
==
NULL
)
{
Py_XDECREF
(
copy
);
return
NULL
;
return
NULL
;
}
}
/* Note: importer is a borrowed reference */
/* Note: importer is a borrowed reference */
...
@@ -1305,7 +1284,6 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
...
@@ -1305,7 +1284,6 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
loader
=
PyObject_CallMethod
(
importer
,
loader
=
PyObject_CallMethod
(
importer
,
"find_module"
,
"find_module"
,
"s"
,
fullname
);
"s"
,
fullname
);
Py_XDECREF
(
copy
);
if
(
loader
==
NULL
)
if
(
loader
==
NULL
)
return
NULL
;
/* error */
return
NULL
;
/* error */
if
(
loader
!=
Py_None
)
{
if
(
loader
!=
Py_None
)
{
...
@@ -1335,7 +1313,6 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
...
@@ -1335,7 +1313,6 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
S_ISDIR
(
statbuf
.
st_mode
)
&&
/* it's a directory */
S_ISDIR
(
statbuf
.
st_mode
)
&&
/* it's a directory */
case_ok
(
buf
,
len
,
namelen
,
name
))
{
/* case matches */
case_ok
(
buf
,
len
,
namelen
,
name
))
{
/* case matches */
if
(
find_init_module
(
buf
))
{
/* and has __init__.py */
if
(
find_init_module
(
buf
))
{
/* and has __init__.py */
Py_XDECREF
(
copy
);
return
&
fd_package
;
return
&
fd_package
;
}
}
else
{
else
{
...
@@ -1345,7 +1322,6 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
...
@@ -1345,7 +1322,6 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
MAXPATHLEN
,
buf
);
MAXPATHLEN
,
buf
);
if
(
PyErr_Warn
(
PyExc_ImportWarning
,
if
(
PyErr_Warn
(
PyExc_ImportWarning
,
warnstr
))
{
warnstr
))
{
Py_XDECREF
(
copy
);
return
NULL
;
return
NULL
;
}
}
}
}
...
@@ -1356,7 +1332,6 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
...
@@ -1356,7 +1332,6 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
if
(
isdir
(
buf
)
&&
if
(
isdir
(
buf
)
&&
case_ok
(
buf
,
len
,
namelen
,
name
))
{
case_ok
(
buf
,
len
,
namelen
,
name
))
{
if
(
find_init_module
(
buf
))
{
if
(
find_init_module
(
buf
))
{
Py_XDECREF
(
copy
);
return
&
fd_package
;
return
&
fd_package
;
}
}
else
{
else
{
...
@@ -1366,7 +1341,6 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
...
@@ -1366,7 +1341,6 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
MAXPATHLEN
,
buf
);
MAXPATHLEN
,
buf
);
if
(
PyErr_Warn
(
PyExc_ImportWarning
,
if
(
PyErr_Warn
(
PyExc_ImportWarning
,
warnstr
))
{
warnstr
))
{
Py_XDECREF
(
copy
);
return
NULL
;
return
NULL
;
}
}
}
}
...
@@ -1436,7 +1410,6 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
...
@@ -1436,7 +1410,6 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
saved_buf
=
NULL
;
saved_buf
=
NULL
;
}
}
#endif
#endif
Py_XDECREF
(
copy
);
if
(
fp
!=
NULL
)
if
(
fp
!=
NULL
)
break
;
break
;
}
}
...
...
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