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
a5d23a19
Kaydet (Commit)
a5d23a19
authored
Ock 20, 2001
tarafından
Skip Montanaro
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
modify urlencode so sequences in the dict are treated as multivalued
parameters. This closes the code part of patch 103314.
üst
a6c861fc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
6 deletions
+36
-6
urllib.py
Lib/urllib.py
+36
-6
No files found.
Lib/urllib.py
Dosyayı görüntüle @
a5d23a19
...
...
@@ -1093,13 +1093,43 @@ def quote_plus(s, safe = ''):
else
:
return
quote
(
s
,
safe
)
def
urlencode
(
dict
):
"""Encode a dictionary of form entries into a URL query string."""
def
urlencode
(
dict
,
doseq
=
0
):
"""Encode a dictionary of form entries into a URL query string.
If any values in the dict are sequences and doseq is true, each
sequence element is converted to a separate parameter.
"""
l
=
[]
for
k
,
v
in
dict
.
items
():
k
=
quote_plus
(
str
(
k
))
v
=
quote_plus
(
str
(
v
))
l
.
append
(
k
+
'='
+
v
)
if
not
doseq
:
# preserve old behavior
for
k
,
v
in
dict
.
items
():
k
=
quote_plus
(
str
(
k
))
v
=
quote_plus
(
str
(
v
))
l
.
append
(
k
+
'='
+
v
)
else
:
for
k
,
v
in
dict
.
items
():
k
=
quote_plus
(
str
(
k
))
if
type
(
v
)
==
types
.
StringType
:
v
=
quote_plus
(
v
)
l
.
append
(
k
+
'='
+
v
)
elif
type
(
v
)
==
types
.
UnicodeType
:
# is there a reasonable way to convert to ASCII?
# encode generates a string, but "replace" or "ignore"
# lose information and "strict" can raise UnicodeError
v
=
quote_plus
(
v
.
encode
(
"ASCII"
,
"replace"
))
l
.
append
(
k
+
'='
+
v
)
else
:
try
:
# is this a sufficient test for sequence-ness?
x
=
len
(
v
)
except
TypeError
:
# not a sequence
v
=
quote_plus
(
str
(
v
))
l
.
append
(
k
+
'='
+
v
)
else
:
# loop over the sequence
for
elt
in
v
:
l
.
append
(
k
+
'='
+
quote_plus
(
str
(
elt
)))
return
'&'
.
join
(
l
)
# Proxy handling
...
...
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