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
98b349f8
Commit
98b349f8
authored
Aug 27, 2007
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some tests I broke. (More to follow.)
parent
1f2ca56e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
4 deletions
+17
-4
Lib/UserString.py
Lib/UserString.py
+10
-0
Lib/base64.py
Lib/base64.py
+6
-3
Lib/test/test_urllib2.py
Lib/test/test_urllib2.py
+1
-1
No files found.
Lib/UserString.py
View file @
98b349f8
...
...
@@ -57,6 +57,8 @@ class UserString:
return
self
.
data
>=
string
def
__contains__
(
self
,
char
):
if
isinstance
(
char
,
UserString
):
char
=
char
.
data
return
char
in
self
.
data
def
__len__
(
self
):
return
len
(
self
.
data
)
...
...
@@ -88,6 +90,8 @@ class UserString:
def
center
(
self
,
width
,
*
args
):
return
self
.
__class__
(
self
.
data
.
center
(
width
,
*
args
))
def
count
(
self
,
sub
,
start
=
0
,
end
=
sys
.
maxint
):
if
isinstance
(
sub
,
UserString
):
sub
=
sub
.
data
return
self
.
data
.
count
(
sub
,
start
,
end
)
def
decode
(
self
,
encoding
=
None
,
errors
=
None
):
# XXX improve this?
if
encoding
:
...
...
@@ -110,6 +114,8 @@ class UserString:
def
expandtabs
(
self
,
tabsize
=
8
):
return
self
.
__class__
(
self
.
data
.
expandtabs
(
tabsize
))
def
find
(
self
,
sub
,
start
=
0
,
end
=
sys
.
maxint
):
if
isinstance
(
sub
,
UserString
):
sub
=
sub
.
data
return
self
.
data
.
find
(
sub
,
start
,
end
)
def
index
(
self
,
sub
,
start
=
0
,
end
=
sys
.
maxint
):
return
self
.
data
.
index
(
sub
,
start
,
end
)
...
...
@@ -130,6 +136,10 @@ class UserString:
def
partition
(
self
,
sep
):
return
self
.
data
.
partition
(
sep
)
def
replace
(
self
,
old
,
new
,
maxsplit
=-
1
):
if
isinstance
(
old
,
UserString
):
old
=
old
.
data
if
isinstance
(
new
,
UserString
):
new
=
new
.
data
return
self
.
__class__
(
self
.
data
.
replace
(
old
,
new
,
maxsplit
))
def
rfind
(
self
,
sub
,
start
=
0
,
end
=
sys
.
maxint
):
return
self
.
data
.
rfind
(
sub
,
start
,
end
)
...
...
Lib/base64.py
View file @
98b349f8
...
...
@@ -28,7 +28,8 @@ __all__ = [
def
_translate
(
s
,
altchars
):
assert
isinstance
(
s
,
bytes
),
type
(
s
)
if
not
isinstance
(
s
,
bytes
):
raise
TypeError
(
"expected bytes, not %s"
%
s
.
__class__
.
__name__
)
translation
=
bytes
(
range
(
256
))
for
k
,
v
in
altchars
.
items
():
translation
[
ord
(
k
)]
=
v
[
0
]
...
...
@@ -323,7 +324,8 @@ def decode(input, output):
def
encodestring
(
s
):
"""Encode a string into multiple lines of base-64 data."""
assert
isinstance
(
s
,
bytes
),
repr
(
s
)
if
not
isinstance
(
s
,
bytes
):
raise
TypeError
(
"expected bytes, not %s"
%
s
.
__class__
.
__name__
)
pieces
=
[]
for
i
in
range
(
0
,
len
(
s
),
MAXBINSIZE
):
chunk
=
s
[
i
:
i
+
MAXBINSIZE
]
...
...
@@ -333,7 +335,8 @@ def encodestring(s):
def
decodestring
(
s
):
"""Decode a string."""
assert
isinstance
(
s
,
bytes
),
repr
(
s
)
if
not
isinstance
(
s
,
bytes
):
raise
TypeError
(
"expected bytes, not %s"
%
s
.
__class__
.
__name__
)
return
binascii
.
a2b_base64
(
s
)
...
...
Lib/test/test_urllib2.py
View file @
98b349f8
...
...
@@ -998,7 +998,7 @@ class HandlerTests(unittest.TestCase):
# expect one request without authorization, then one with
self
.
assertEqual
(
len
(
http_handler
.
requests
),
2
)
self
.
assertFalse
(
http_handler
.
requests
[
0
].
has_header
(
auth_header
))
userpass
=
'%s:%s'
%
(
user
,
password
)
userpass
=
bytes
(
'%s:%s'
%
(
user
,
password
),
"ascii"
)
auth_hdr_value
=
'Basic '
+
str
(
base64
.
encodestring
(
userpass
)).
strip
()
self
.
assertEqual
(
http_handler
.
requests
[
1
].
get_header
(
auth_header
),
auth_hdr_value
)
...
...
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