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
6b71e747
Commit
6b71e747
authored
Feb 09, 2001
by
Eric S. Raymond
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
String method conversion.
parent
141971f2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
18 deletions
+14
-18
Lib/CGIHTTPServer.py
Lib/CGIHTTPServer.py
+7
-7
Lib/code.py
Lib/code.py
+1
-2
Lib/codeop.py
Lib/codeop.py
+2
-3
Lib/py_compile.py
Lib/py_compile.py
+2
-2
Lib/repr.py
Lib/repr.py
+2
-4
No files found.
Lib/CGIHTTPServer.py
View file @
6b71e747
...
@@ -103,12 +103,12 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
...
@@ -103,12 +103,12 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def
run_cgi
(
self
):
def
run_cgi
(
self
):
"""Execute a CGI script."""
"""Execute a CGI script."""
dir
,
rest
=
self
.
cgi_info
dir
,
rest
=
self
.
cgi_info
i
=
string
.
rfind
(
rest
,
'?'
)
i
=
rest
.
rfind
(
'?'
)
if
i
>=
0
:
if
i
>=
0
:
rest
,
query
=
rest
[:
i
],
rest
[
i
+
1
:]
rest
,
query
=
rest
[:
i
],
rest
[
i
+
1
:]
else
:
else
:
query
=
''
query
=
''
i
=
string
.
find
(
rest
,
'/'
)
i
=
rest
.
find
(
'/'
)
if
i
>=
0
:
if
i
>=
0
:
script
,
rest
=
rest
[:
i
],
rest
[
i
:]
script
,
rest
=
rest
[:
i
],
rest
[
i
:]
else
:
else
:
...
@@ -165,16 +165,16 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
...
@@ -165,16 +165,16 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
accept
=
[]
accept
=
[]
for
line
in
self
.
headers
.
getallmatchingheaders
(
'accept'
):
for
line
in
self
.
headers
.
getallmatchingheaders
(
'accept'
):
if
line
[:
1
]
in
string
.
whitespace
:
if
line
[:
1
]
in
string
.
whitespace
:
accept
.
append
(
string
.
strip
(
line
))
accept
.
append
(
line
.
strip
(
))
else
:
else
:
accept
=
accept
+
string
.
split
(
line
[
7
:],
','
)
accept
=
accept
+
line
[
7
:].
split
(
','
)
env
[
'HTTP_ACCEPT'
]
=
string
.
joinfields
(
accept
,
','
)
env
[
'HTTP_ACCEPT'
]
=
','
.
join
(
accept
)
ua
=
self
.
headers
.
getheader
(
'user-agent'
)
ua
=
self
.
headers
.
getheader
(
'user-agent'
)
if
ua
:
if
ua
:
env
[
'HTTP_USER_AGENT'
]
=
ua
env
[
'HTTP_USER_AGENT'
]
=
ua
co
=
filter
(
None
,
self
.
headers
.
getheaders
(
'cookie'
))
co
=
filter
(
None
,
self
.
headers
.
getheaders
(
'cookie'
))
if
co
:
if
co
:
env
[
'HTTP_COOKIE'
]
=
string
.
join
(
co
,
', '
)
env
[
'HTTP_COOKIE'
]
=
', '
.
join
(
co
)
# XXX Other HTTP_* headers
# XXX Other HTTP_* headers
if
not
self
.
have_fork
:
if
not
self
.
have_fork
:
# Since we're setting the env in the parent, provide empty
# Since we're setting the env in the parent, provide empty
...
@@ -185,7 +185,7 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
...
@@ -185,7 +185,7 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
self
.
send_response
(
200
,
"Script output follows"
)
self
.
send_response
(
200
,
"Script output follows"
)
decoded_query
=
string
.
replace
(
query
,
'+'
,
' '
)
decoded_query
=
query
.
replace
(
'+'
,
' '
)
if
self
.
have_fork
:
if
self
.
have_fork
:
# Unix -- fork as we should
# Unix -- fork as we should
...
...
Lib/code.py
View file @
6b71e747
...
@@ -6,7 +6,6 @@
...
@@ -6,7 +6,6 @@
import
sys
import
sys
import
string
import
traceback
import
traceback
from
codeop
import
compile_command
from
codeop
import
compile_command
...
@@ -260,7 +259,7 @@ class InteractiveConsole(InteractiveInterpreter):
...
@@ -260,7 +259,7 @@ class InteractiveConsole(InteractiveInterpreter):
"""
"""
self
.
buffer
.
append
(
line
)
self
.
buffer
.
append
(
line
)
source
=
string
.
join
(
self
.
buffer
,
"
\
n
"
)
source
=
"
\
n
"
.
join
(
self
.
buffer
)
more
=
self
.
runsource
(
source
,
self
.
filename
)
more
=
self
.
runsource
(
source
,
self
.
filename
)
if
not
more
:
if
not
more
:
self
.
resetbuffer
()
self
.
resetbuffer
()
...
...
Lib/codeop.py
View file @
6b71e747
"""Utility to compile possibly incomplete Python source code."""
"""Utility to compile possibly incomplete Python source code."""
import
sys
import
sys
import
string
import
traceback
import
traceback
__all__
=
[
"compile_command"
]
__all__
=
[
"compile_command"
]
...
@@ -49,8 +48,8 @@ def compile_command(source, filename="<input>", symbol="single"):
...
@@ -49,8 +48,8 @@ def compile_command(source, filename="<input>", symbol="single"):
"""
"""
# Check for source consisting of only blank lines and comments
# Check for source consisting of only blank lines and comments
for
line
in
s
tring
.
split
(
source
,
"
\
n
"
):
for
line
in
s
ource
.
split
(
"
\
n
"
):
line
=
string
.
strip
(
line
)
line
=
line
.
strip
(
)
if
line
and
line
[
0
]
!=
'#'
:
if
line
and
line
[
0
]
!=
'#'
:
break
# Leave it alone
break
# Leave it alone
else
:
else
:
...
...
Lib/py_compile.py
View file @
6b71e747
...
@@ -59,10 +59,10 @@ def compile(file, cfile=None, dfile=None):
...
@@ -59,10 +59,10 @@ def compile(file, cfile=None, dfile=None):
try
:
try
:
codeobject
=
__builtin__
.
compile
(
codestring
,
dfile
or
file
,
'exec'
)
codeobject
=
__builtin__
.
compile
(
codestring
,
dfile
or
file
,
'exec'
)
except
SyntaxError
,
detail
:
except
SyntaxError
,
detail
:
import
traceback
,
sys
,
string
import
traceback
,
sys
lines
=
traceback
.
format_exception_only
(
SyntaxError
,
detail
)
lines
=
traceback
.
format_exception_only
(
SyntaxError
,
detail
)
for
line
in
lines
:
for
line
in
lines
:
sys
.
stderr
.
write
(
string
.
replace
(
line
,
'File "<string>"'
,
sys
.
stderr
.
write
(
line
.
replace
(
'File "<string>"'
,
'File "%s"'
%
(
dfile
or
file
)))
'File "%s"'
%
(
dfile
or
file
)))
return
return
if
not
cfile
:
if
not
cfile
:
...
...
Lib/repr.py
View file @
6b71e747
"""Redo the `...` (representation) but with limits on most sizes."""
"""Redo the `...` (representation) but with limits on most sizes."""
import
string
class
Repr
:
class
Repr
:
def
__init__
(
self
):
def
__init__
(
self
):
self
.
maxlevel
=
6
self
.
maxlevel
=
6
...
@@ -16,8 +14,8 @@ class Repr:
...
@@ -16,8 +14,8 @@ class Repr:
def
repr1
(
self
,
x
,
level
):
def
repr1
(
self
,
x
,
level
):
typename
=
`type(x)`
[
7
:
-
2
]
# "<type '......'>"
typename
=
`type(x)`
[
7
:
-
2
]
# "<type '......'>"
if
' '
in
typename
:
if
' '
in
typename
:
parts
=
string
.
split
(
typename
)
parts
=
typename
.
split
(
)
typename
=
string
.
joinfields
(
parts
,
'_'
)
typename
=
'_'
.
join
(
parts
)
if
hasattr
(
self
,
'repr_'
+
typename
):
if
hasattr
(
self
,
'repr_'
+
typename
):
return
getattr
(
self
,
'repr_'
+
typename
)(
x
,
level
)
return
getattr
(
self
,
'repr_'
+
typename
)(
x
,
level
)
else
:
else
:
...
...
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