Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
d451ec1c
Commit
d451ec1c
authored
Apr 26, 2002
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up uses of some deprecated features.
Reported by Neal Norwitz on python-dev.
parent
89e3ee0c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
17 deletions
+20
-17
Lib/ConfigParser.py
Lib/ConfigParser.py
+2
-2
Lib/Cookie.py
Lib/Cookie.py
+16
-13
Lib/inspect.py
Lib/inspect.py
+2
-2
No files found.
Lib/ConfigParser.py
View file @
d451ec1c
...
...
@@ -301,10 +301,10 @@ class ConfigParser:
return
conv
(
self
.
get
(
section
,
option
))
def
getint
(
self
,
section
,
option
):
return
self
.
__get
(
section
,
string
.
atoi
,
option
)
return
self
.
__get
(
section
,
int
,
option
)
def
getfloat
(
self
,
section
,
option
):
return
self
.
__get
(
section
,
string
.
atof
,
option
)
return
self
.
__get
(
section
,
float
,
option
)
def
getboolean
(
self
,
section
,
option
):
states
=
{
'1'
:
1
,
'yes'
:
1
,
'true'
:
1
,
'on'
:
1
,
...
...
Lib/Cookie.py
View file @
d451ec1c
...
...
@@ -231,6 +231,9 @@ except ImportError:
__all__
=
[
"CookieError"
,
"BaseCookie"
,
"SimpleCookie"
,
"SerialCookie"
,
"SmartCookie"
,
"Cookie"
]
_nulljoin
=
''
.
join
_spacejoin
=
' '
.
join
#
# Define an exception visible to External modules
#
...
...
@@ -311,7 +314,7 @@ _Translator = {
}
def
_quote
(
str
,
LegalChars
=
_LegalChars
,
join
=
string
.
join
,
idmap
=
string
.
_idmap
,
translate
=
string
.
translate
):
idmap
=
string
.
_idmap
,
translate
=
string
.
translate
):
#
# If the string does not need to be double-quoted,
# then just return the string. Otherwise, surround
...
...
@@ -321,14 +324,14 @@ def _quote(str, LegalChars=_LegalChars,
if
""
==
translate
(
str
,
idmap
,
LegalChars
):
return
str
else
:
return
'"'
+
join
(
map
(
_Translator
.
get
,
str
,
str
),
""
)
+
'"'
return
'"'
+
_nulljoin
(
map
(
_Translator
.
get
,
str
,
str
)
)
+
'"'
# end _quote
_OctalPatt
=
re
.
compile
(
r"\\[0-3][0-7][0-7]"
)
_QuotePatt
=
re
.
compile
(
r"[\\]."
)
def
_unquote
(
str
,
join
=
string
.
join
,
atoi
=
string
.
atoi
):
def
_unquote
(
str
):
# If there aren't any doublequotes,
# then there can't be any special characters. See RFC 2109.
if
len
(
str
)
<
2
:
...
...
@@ -365,9 +368,9 @@ def _unquote(str, join=string.join, atoi=string.atoi):
i
=
k
+
2
else
:
# OctalPatt matched
res
.
append
(
str
[
i
:
j
])
res
.
append
(
chr
(
atoi
(
str
[
j
+
1
:
j
+
4
],
8
)
)
)
res
.
append
(
chr
(
int
(
str
[
j
+
1
:
j
+
4
],
8
)
)
)
i
=
j
+
4
return
join
(
res
,
""
)
return
_nulljoin
(
res
)
# end _unquote
# The _getdate() routine is used to set the expiration time in
...
...
@@ -435,14 +438,14 @@ class Morsel(UserDict):
# end __init__
def
__setitem__
(
self
,
K
,
V
):
K
=
string
.
lower
(
K
)
K
=
K
.
lower
(
)
if
not
K
in
self
.
_reserved_keys
:
raise
CookieError
(
"Invalid Attribute %s"
%
K
)
UserDict
.
__setitem__
(
self
,
K
,
V
)
# end __setitem__
def
isReservedKey
(
self
,
K
):
return
string
.
lower
(
K
)
in
self
.
_reserved_keys
return
K
.
lower
(
)
in
self
.
_reserved_keys
# end isReservedKey
def
set
(
self
,
key
,
val
,
coded_val
,
...
...
@@ -450,7 +453,7 @@ class Morsel(UserDict):
idmap
=
string
.
_idmap
,
translate
=
string
.
translate
):
# First we verify that the key isn't a reserved word
# Second we make sure it only contains legal characters
if
string
.
lower
(
key
)
in
self
.
_reserved_keys
:
if
key
.
lower
(
)
in
self
.
_reserved_keys
:
raise
CookieError
(
"Attempt to set a reserved key: %s"
%
key
)
if
""
!=
translate
(
key
,
idmap
,
LegalChars
):
raise
CookieError
(
"Illegal key value: %s"
%
key
)
...
...
@@ -508,7 +511,7 @@ class Morsel(UserDict):
RA
(
"%s=%s;"
%
(
self
.
_reserved
[
K
],
V
))
# Return the result
return
string
.
join
(
result
,
" "
)
return
_spacejoin
(
result
)
# end OutputString
# end Morsel class
...
...
@@ -592,7 +595,7 @@ class BaseCookie(UserDict):
items
.
sort
()
for
K
,
V
in
items
:
result
.
append
(
V
.
output
(
attrs
,
header
)
)
return
s
tring
.
join
(
result
,
sep
)
return
s
ep
.
join
(
result
)
# end output
__str__
=
output
...
...
@@ -603,7 +606,7 @@ class BaseCookie(UserDict):
items
.
sort
()
for
K
,
V
in
items
:
L
.
append
(
'%s=%s'
%
(
K
,
repr
(
V
.
value
)
)
)
return
'<%s: %s>'
%
(
self
.
__class__
.
__name__
,
string
.
join
(
L
))
return
'<%s: %s>'
%
(
self
.
__class__
.
__name__
,
_space
join
(
L
))
def
js_output
(
self
,
attrs
=
None
):
"""Return a string suitable for JavaScript."""
...
...
@@ -612,7 +615,7 @@ class BaseCookie(UserDict):
items
.
sort
()
for
K
,
V
in
items
:
result
.
append
(
V
.
js_output
(
attrs
)
)
return
string
.
join
(
result
,
""
)
return
_nulljoin
(
result
)
# end js_output
def
load
(
self
,
rawdata
):
...
...
@@ -648,7 +651,7 @@ class BaseCookie(UserDict):
# (Does anyone care?)
if
M
:
M
[
K
[
1
:]
]
=
V
elif
string
.
lower
(
K
)
in
Morsel
.
_reserved_keys
:
elif
K
.
lower
(
)
in
Morsel
.
_reserved_keys
:
if
M
:
M
[
K
]
=
_unquote
(
V
)
else
:
...
...
Lib/inspect.py
View file @
d451ec1c
...
...
@@ -769,7 +769,7 @@ def currentframe():
try
:
1
/
0
except
ZeroDivisionError
:
return
sys
.
exc_
traceback
.
tb_frame
.
f_back
return
sys
.
exc_
info
()[
2
]
.
tb_frame
.
f_back
if
hasattr
(
sys
,
'_getframe'
):
currentframe
=
sys
.
_getframe
...
...
@@ -779,4 +779,4 @@ def stack(context=1):
def
trace
(
context
=
1
):
"""Return a list of records for the stack below the current exception."""
return
getinnerframes
(
sys
.
exc_
traceback
,
context
)
return
getinnerframes
(
sys
.
exc_
info
()[
2
]
,
context
)
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