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
e854e765
Kaydet (Commit)
e854e765
authored
May 08, 2006
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Patch #1478993: take advantage of BaseException/Exception split in cookielib
üst
b5f2e5cc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
29 deletions
+35
-29
_LWPCookieJar.py
Lib/_LWPCookieJar.py
+13
-7
_MozillaCookieJar.py
Lib/_MozillaCookieJar.py
+8
-6
cookielib.py
Lib/cookielib.py
+14
-16
No files found.
Lib/_LWPCookieJar.py
Dosyayı görüntüle @
e854e765
...
...
@@ -12,9 +12,10 @@ libwww-perl, I hope.
"""
import
time
,
re
,
logging
from
cookielib
import
(
reraise_unmasked_exceptions
,
FileCookieJar
,
LoadError
,
Cookie
,
MISSING_FILENAME_TEXT
,
join_header_words
,
split_header_words
,
iso2time
,
time2isoz
)
from
cookielib
import
(
_warn_unhandled_exception
,
FileCookieJar
,
LoadError
,
Cookie
,
MISSING_FILENAME_TEXT
,
join_header_words
,
split_header_words
,
iso2time
,
time2isoz
)
def
lwp_cookie_str
(
cookie
):
"""Return string representation of Cookie in an the LWP cookie file format.
...
...
@@ -92,7 +93,8 @@ class LWPCookieJar(FileCookieJar):
def
_really_load
(
self
,
f
,
filename
,
ignore_discard
,
ignore_expires
):
magic
=
f
.
readline
()
if
not
re
.
search
(
self
.
magic_re
,
magic
):
msg
=
"
%
s does not seem to contain cookies"
%
filename
msg
=
(
"
%
r does not look like a Set-Cookie3 (LWP) format "
"file"
%
filename
)
raise
LoadError
(
msg
)
now
=
time
.
time
()
...
...
@@ -159,6 +161,10 @@ class LWPCookieJar(FileCookieJar):
if
not
ignore_expires
and
c
.
is_expired
(
now
):
continue
self
.
set_cookie
(
c
)
except
:
reraise_unmasked_exceptions
((
IOError
,))
raise
LoadError
(
"invalid Set-Cookie3 format file
%
s"
%
filename
)
except
IOError
:
raise
except
Exception
:
_warn_unhandled_exception
()
raise
LoadError
(
"invalid Set-Cookie3 format file
%
r:
%
r"
%
(
filename
,
line
))
Lib/_MozillaCookieJar.py
Dosyayı görüntüle @
e854e765
...
...
@@ -2,8 +2,8 @@
import
re
,
time
,
logging
from
cookielib
import
(
reraise_unmasked_exceptions
,
FileCookieJar
,
LoadError
,
Cookie
,
MISSING_FILENAME_TEXT
)
from
cookielib
import
(
_warn_unhandled_exception
,
FileCookieJar
,
LoadError
,
Cookie
,
MISSING_FILENAME_TEXT
)
class
MozillaCookieJar
(
FileCookieJar
):
"""
...
...
@@ -51,7 +51,7 @@ class MozillaCookieJar(FileCookieJar):
if
not
re
.
search
(
self
.
magic_re
,
magic
):
f
.
close
()
raise
LoadError
(
"
%
s
does not look like a Netscape format cookies file"
%
"
%
r
does not look like a Netscape format cookies file"
%
filename
)
try
:
...
...
@@ -104,9 +104,11 @@ class MozillaCookieJar(FileCookieJar):
continue
self
.
set_cookie
(
c
)
except
:
reraise_unmasked_exceptions
((
IOError
,))
raise
LoadError
(
"invalid Netscape format file
%
s:
%
s"
%
except
IOError
:
raise
except
Exception
:
_warn_unhandled_exception
()
raise
LoadError
(
"invalid Netscape format cookies file
%
r:
%
r"
%
(
filename
,
line
))
def
save
(
self
,
filename
=
None
,
ignore_discard
=
False
,
ignore_expires
=
False
):
...
...
Lib/cookielib.py
Dosyayı görüntüle @
e854e765
...
...
@@ -7,9 +7,9 @@ Docstrings, comments and debug strings in this code refer to the
attributes of the HTTP cookie system as cookie-attributes, to distinguish
them clearly from Python attributes.
Class diagram (note that
the classes which do not derive from
FileCookieJar are not distributed with the Python standard library, but
are available from
http://wwwsearch.sf.net/):
Class diagram (note that
BSDDBCookieJar and the MSIE* classes are not
distributed with the Python standard library, but are available from
http://wwwsearch.sf.net/):
CookieJar____
/
\
\
...
...
@@ -25,7 +25,10 @@ are available from http://wwwsearch.sf.net/):
"""
import
sys
,
re
,
urlparse
,
copy
,
time
,
urllib
,
logging
__all__
=
[
'Cookie'
,
'CookieJar'
,
'CookiePolicy'
,
'DefaultCookiePolicy'
,
'FileCookieJar'
,
'LWPCookieJar'
,
'LoadError'
,
'MozillaCookieJar'
]
import
re
,
urlparse
,
copy
,
time
,
urllib
,
logging
try
:
import
threading
as
_threading
except
ImportError
:
...
...
@@ -39,15 +42,10 @@ DEFAULT_HTTP_PORT = str(httplib.HTTP_PORT)
MISSING_FILENAME_TEXT
=
(
"a filename was not supplied (nor was the CookieJar "
"instance initialised with one)"
)
def
reraise_unmasked_exceptions
(
unmasked
=
()
):
def
_warn_unhandled_exception
(
):
# There are a few catch-all except: statements in this module, for
# catching input that's bad in unexpected ways.
# This function re-raises some exceptions we don't want to trap.
unmasked
=
unmasked
+
(
KeyboardInterrupt
,
SystemExit
,
MemoryError
)
etype
=
sys
.
exc_info
()[
0
]
if
issubclass
(
etype
,
unmasked
):
raise
# swallowed an exception
# catching input that's bad in unexpected ways. Warn if any
# exceptions are caught there.
import
warnings
,
traceback
,
StringIO
f
=
StringIO
.
StringIO
()
traceback
.
print_exc
(
None
,
f
)
...
...
@@ -1555,8 +1553,8 @@ class CookieJar:
try
:
cookies
=
self
.
_cookies_from_attrs_set
(
split_header_words
(
rfc2965_hdrs
),
request
)
except
:
reraise_unmasked_exceptions
()
except
Exception
:
_warn_unhandled_exception
()
cookies
=
[]
if
ns_hdrs
and
netscape
:
...
...
@@ -1564,8 +1562,8 @@ class CookieJar:
# RFC 2109 and Netscape cookies
ns_cookies
=
self
.
_cookies_from_attrs_set
(
parse_ns_headers
(
ns_hdrs
),
request
)
except
:
reraise_unmasked_exceptions
()
except
Exception
:
_warn_unhandled_exception
()
ns_cookies
=
[]
self
.
_process_rfc2109_cookies
(
ns_cookies
)
...
...
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