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
a617271d
Kaydet (Commit)
a617271d
authored
Ara 31, 2004
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Use cStringIO where available.
üst
54266fce
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
55 additions
and
19 deletions
+55
-19
SimpleHTTPServer.py
Lib/SimpleHTTPServer.py
+4
-1
SocketServer.py
Lib/SocketServer.py
+6
-3
cgi.py
Lib/cgi.py
+4
-1
gettext.py
Lib/gettext.py
+4
-1
mhlib.py
Lib/mhlib.py
+4
-1
tarfile.py
Lib/tarfile.py
+5
-2
urllib.py
Lib/urllib.py
+23
-8
urlparse.py
Lib/urlparse.py
+5
-2
No files found.
Lib/SimpleHTTPServer.py
Dosyayı görüntüle @
a617271d
...
@@ -17,7 +17,10 @@ import urllib
...
@@ -17,7 +17,10 @@ import urllib
import
cgi
import
cgi
import
shutil
import
shutil
import
mimetypes
import
mimetypes
from
StringIO
import
StringIO
try
:
from
cStringIO
import
StringIO
except
ImportError
:
from
StringIO
import
StringIO
class
SimpleHTTPRequestHandler
(
BaseHTTPServer
.
BaseHTTPRequestHandler
):
class
SimpleHTTPRequestHandler
(
BaseHTTPServer
.
BaseHTTPRequestHandler
):
...
...
Lib/SocketServer.py
Dosyayı görüntüle @
a617271d
...
@@ -575,10 +575,13 @@ class DatagramRequestHandler(BaseRequestHandler):
...
@@ -575,10 +575,13 @@ class DatagramRequestHandler(BaseRequestHandler):
"""Define self.rfile and self.wfile for datagram sockets."""
"""Define self.rfile and self.wfile for datagram sockets."""
def
setup
(
self
):
def
setup
(
self
):
import
StringIO
try
:
from
cStringIO
import
StringIO
except
ImportError
:
from
StringIO
import
StringIO
self
.
packet
,
self
.
socket
=
self
.
request
self
.
packet
,
self
.
socket
=
self
.
request
self
.
rfile
=
StringIO
.
StringIO
(
self
.
packet
)
self
.
rfile
=
StringIO
(
self
.
packet
)
self
.
wfile
=
StringIO
.
StringIO
()
self
.
wfile
=
StringIO
()
def
finish
(
self
):
def
finish
(
self
):
self
.
socket
.
sendto
(
self
.
wfile
.
getvalue
(),
self
.
client_address
)
self
.
socket
.
sendto
(
self
.
wfile
.
getvalue
(),
self
.
client_address
)
Lib/cgi.py
Dosyayı görüntüle @
a617271d
...
@@ -40,7 +40,10 @@ import urllib
...
@@ -40,7 +40,10 @@ import urllib
import
mimetools
import
mimetools
import
rfc822
import
rfc822
import
UserDict
import
UserDict
from
StringIO
import
StringIO
try
:
from
cStringIO
import
StringIO
except
ImportError
:
from
StringIO
import
StringIO
__all__
=
[
"MiniFieldStorage"
,
"FieldStorage"
,
"FormContentDict"
,
__all__
=
[
"MiniFieldStorage"
,
"FieldStorage"
,
"FormContentDict"
,
"SvFormContentDict"
,
"InterpFormContentDict"
,
"FormContent"
,
"SvFormContentDict"
,
"InterpFormContentDict"
,
"FormContent"
,
...
...
Lib/gettext.py
Dosyayı görüntüle @
a617271d
...
@@ -77,7 +77,10 @@ def c2py(plural):
...
@@ -77,7 +77,10 @@ def c2py(plural):
Python lambda function that implements an equivalent expression.
Python lambda function that implements an equivalent expression.
"""
"""
# Security check, allow only the "n" identifier
# Security check, allow only the "n" identifier
from
StringIO
import
StringIO
try
:
from
cStringIO
import
StringIO
except
ImportError
:
from
StringIO
import
StringIO
import
token
,
tokenize
import
token
,
tokenize
tokens
=
tokenize
.
generate_tokens
(
StringIO
(
plural
)
.
readline
)
tokens
=
tokenize
.
generate_tokens
(
StringIO
(
plural
)
.
readline
)
try
:
try
:
...
...
Lib/mhlib.py
Dosyayı görüntüle @
a617271d
...
@@ -697,7 +697,10 @@ class Message(mimetools.Message):
...
@@ -697,7 +697,10 @@ class Message(mimetools.Message):
encoding
=
self
.
getencoding
()
encoding
=
self
.
getencoding
()
if
not
decode
or
encoding
in
(
''
,
'7bit'
,
'8bit'
,
'binary'
):
if
not
decode
or
encoding
in
(
''
,
'7bit'
,
'8bit'
,
'binary'
):
return
self
.
fp
.
read
()
return
self
.
fp
.
read
()
from
StringIO
import
StringIO
try
:
from
cStringIO
import
StringIO
except
ImportError
:
from
StringIO
import
StringIO
output
=
StringIO
()
output
=
StringIO
()
mimetools
.
decode
(
self
.
fp
,
output
,
encoding
)
mimetools
.
decode
(
self
.
fp
,
output
,
encoding
)
return
output
.
getvalue
()
return
output
.
getvalue
()
...
...
Lib/tarfile.py
Dosyayı görüntüle @
a617271d
...
@@ -1936,12 +1936,15 @@ class TarFileCompat:
...
@@ -1936,12 +1936,15 @@ class TarFileCompat:
def
write
(
self
,
filename
,
arcname
=
None
,
compress_type
=
None
):
def
write
(
self
,
filename
,
arcname
=
None
,
compress_type
=
None
):
self
.
tarfile
.
add
(
filename
,
arcname
)
self
.
tarfile
.
add
(
filename
,
arcname
)
def
writestr
(
self
,
zinfo
,
bytes
):
def
writestr
(
self
,
zinfo
,
bytes
):
import
StringIO
try
:
from
cStringIO
import
StringIO
except
ImportError
:
from
StringIO
import
StringIO
import
calendar
import
calendar
zinfo
.
name
=
zinfo
.
filename
zinfo
.
name
=
zinfo
.
filename
zinfo
.
size
=
zinfo
.
file_size
zinfo
.
size
=
zinfo
.
file_size
zinfo
.
mtime
=
calendar
.
timegm
(
zinfo
.
date_time
)
zinfo
.
mtime
=
calendar
.
timegm
(
zinfo
.
date_time
)
self
.
tarfile
.
addfile
(
zinfo
,
StringIO
.
StringIO
(
bytes
))
self
.
tarfile
.
addfile
(
zinfo
,
StringIO
(
bytes
))
def
close
(
self
):
def
close
(
self
):
self
.
tarfile
.
close
()
self
.
tarfile
.
close
()
#class TarFileCompat
#class TarFileCompat
...
...
Lib/urllib.py
Dosyayı görüntüle @
a617271d
...
@@ -410,7 +410,11 @@ class URLopener:
...
@@ -410,7 +410,11 @@ class URLopener:
def
open_local_file
(
self
,
url
):
def
open_local_file
(
self
,
url
):
"""Use local file."""
"""Use local file."""
import
mimetypes
,
mimetools
,
email
.
Utils
,
StringIO
import
mimetypes
,
mimetools
,
email
.
Utils
try
:
from
cStringIO
import
StringIO
except
ImportError
:
from
StringIO
import
StringIO
host
,
file
=
splithost
(
url
)
host
,
file
=
splithost
(
url
)
localname
=
url2pathname
(
file
)
localname
=
url2pathname
(
file
)
try
:
try
:
...
@@ -420,7 +424,7 @@ class URLopener:
...
@@ -420,7 +424,7 @@ class URLopener:
size
=
stats
.
st_size
size
=
stats
.
st_size
modified
=
email
.
Utils
.
formatdate
(
stats
.
st_mtime
,
usegmt
=
True
)
modified
=
email
.
Utils
.
formatdate
(
stats
.
st_mtime
,
usegmt
=
True
)
mtype
=
mimetypes
.
guess_type
(
url
)[
0
]
mtype
=
mimetypes
.
guess_type
(
url
)[
0
]
headers
=
mimetools
.
Message
(
StringIO
.
StringIO
(
headers
=
mimetools
.
Message
(
StringIO
(
'Content-Type:
%
s
\n
Content-Length:
%
d
\n
Last-modified:
%
s
\n
'
%
'Content-Type:
%
s
\n
Content-Length:
%
d
\n
Last-modified:
%
s
\n
'
%
(
mtype
or
'text/plain'
,
size
,
modified
)))
(
mtype
or
'text/plain'
,
size
,
modified
)))
if
not
host
:
if
not
host
:
...
@@ -441,7 +445,11 @@ class URLopener:
...
@@ -441,7 +445,11 @@ class URLopener:
def
open_ftp
(
self
,
url
):
def
open_ftp
(
self
,
url
):
"""Use FTP protocol."""
"""Use FTP protocol."""
import
mimetypes
,
mimetools
,
StringIO
import
mimetypes
,
mimetools
try
:
from
cStringIO
import
StringIO
except
ImportError
:
from
StringIO
import
StringIO
host
,
path
=
splithost
(
url
)
host
,
path
=
splithost
(
url
)
if
not
host
:
raise
IOError
,
(
'ftp error'
,
'no host given'
)
if
not
host
:
raise
IOError
,
(
'ftp error'
,
'no host given'
)
host
,
port
=
splitport
(
host
)
host
,
port
=
splitport
(
host
)
...
@@ -490,7 +498,7 @@ class URLopener:
...
@@ -490,7 +498,7 @@ class URLopener:
headers
+=
"Content-Type:
%
s
\n
"
%
mtype
headers
+=
"Content-Type:
%
s
\n
"
%
mtype
if
retrlen
is
not
None
and
retrlen
>=
0
:
if
retrlen
is
not
None
and
retrlen
>=
0
:
headers
+=
"Content-Length:
%
d
\n
"
%
retrlen
headers
+=
"Content-Length:
%
d
\n
"
%
retrlen
headers
=
mimetools
.
Message
(
StringIO
.
StringIO
(
headers
))
headers
=
mimetools
.
Message
(
StringIO
(
headers
))
return
addinfourl
(
fp
,
headers
,
"ftp:"
+
url
)
return
addinfourl
(
fp
,
headers
,
"ftp:"
+
url
)
except
ftperrors
(),
msg
:
except
ftperrors
(),
msg
:
raise
IOError
,
(
'ftp error'
,
msg
),
sys
.
exc_info
()[
2
]
raise
IOError
,
(
'ftp error'
,
msg
),
sys
.
exc_info
()[
2
]
...
@@ -504,7 +512,11 @@ class URLopener:
...
@@ -504,7 +512,11 @@ class URLopener:
# mediatype := [ type "/" subtype ] *( ";" parameter )
# mediatype := [ type "/" subtype ] *( ";" parameter )
# data := *urlchar
# data := *urlchar
# parameter := attribute "=" value
# parameter := attribute "=" value
import
StringIO
,
mimetools
import
mimetools
try
:
from
cStringIO
import
StringIO
except
ImportError
:
from
StringIO
import
StringIO
try
:
try
:
[
type
,
data
]
=
url
.
split
(
','
,
1
)
[
type
,
data
]
=
url
.
split
(
','
,
1
)
except
ValueError
:
except
ValueError
:
...
@@ -530,7 +542,7 @@ class URLopener:
...
@@ -530,7 +542,7 @@ class URLopener:
msg
.
append
(
''
)
msg
.
append
(
''
)
msg
.
append
(
data
)
msg
.
append
(
data
)
msg
=
'
\n
'
.
join
(
msg
)
msg
=
'
\n
'
.
join
(
msg
)
f
=
StringIO
.
StringIO
(
msg
)
f
=
StringIO
(
msg
)
headers
=
mimetools
.
Message
(
f
,
0
)
headers
=
mimetools
.
Message
(
f
,
0
)
f
.
fileno
=
None
# needed for addinfourl
f
.
fileno
=
None
# needed for addinfourl
return
addinfourl
(
f
,
headers
,
url
)
return
addinfourl
(
f
,
headers
,
url
)
...
@@ -697,8 +709,11 @@ def noheaders():
...
@@ -697,8 +709,11 @@ def noheaders():
global
_noheaders
global
_noheaders
if
_noheaders
is
None
:
if
_noheaders
is
None
:
import
mimetools
import
mimetools
import
StringIO
try
:
_noheaders
=
mimetools
.
Message
(
StringIO
.
StringIO
(),
0
)
from
cStringIO
import
StringIO
except
ImportError
:
from
StringIO
import
StringIO
_noheaders
=
mimetools
.
Message
(
StringIO
(),
0
)
_noheaders
.
fp
.
close
()
# Recycle file descriptor
_noheaders
.
fp
.
close
()
# Recycle file descriptor
return
_noheaders
return
_noheaders
...
...
Lib/urlparse.py
Dosyayı görüntüle @
a617271d
...
@@ -243,8 +243,11 @@ def test():
...
@@ -243,8 +243,11 @@ def test():
else
:
else
:
fp
=
open
(
fn
)
fp
=
open
(
fn
)
else
:
else
:
import
StringIO
try
:
fp
=
StringIO
.
StringIO
(
test_input
)
from
cStringIO
import
StringIO
except
ImportError
:
from
StringIO
import
StringIO
fp
=
StringIO
(
test_input
)
while
1
:
while
1
:
line
=
fp
.
readline
()
line
=
fp
.
readline
()
if
not
line
:
break
if
not
line
:
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