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
3eec12b3
Commit
3eec12b3
authored
Aug 05, 2012
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Plain Diff
merge heads
parents
a2f028c1
d0948df3
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
890 additions
and
395 deletions
+890
-395
Doc/library/ipaddress.rst
Doc/library/ipaddress.rst
+443
-74
Doc/library/os.rst
Doc/library/os.rst
+3
-3
Doc/whatsnew/3.3.rst
Doc/whatsnew/3.3.rst
+189
-102
Lib/gzip.py
Lib/gzip.py
+4
-2
Lib/ipaddress.py
Lib/ipaddress.py
+225
-195
Lib/test/test_httpservers.py
Lib/test/test_httpservers.py
+7
-5
Lib/test/test_ipaddress.py
Lib/test/test_ipaddress.py
+13
-12
Misc/NEWS
Misc/NEWS
+6
-2
No files found.
Doc/library/ipaddress.rst
View file @
3eec12b3
This diff is collapsed.
Click to expand it.
Doc/library/os.rst
View file @
3eec12b3
...
...
@@ -2248,7 +2248,7 @@ features:
dirs.remove('CVS') # don't visit CVS directories
In the next example, walking the tree bottom-up is essential:
:func:`
unlinkat
` doesn't allow deleting a directory before the directory is
:func:`
rmdir
` doesn't allow deleting a directory before the directory is
empty::
# Delete everything reachable from the directory named in "top",
...
...
@@ -2258,9 +2258,9 @@ features:
import os
for root, dirs, files, rootfd in os.fwalk(top, topdown=False):
for name in files:
os.unlink
at(rootfd, name
)
os.unlink
(name, dir_fd=rootfd
)
for name in dirs:
os.
unlinkat(rootfd, name, os.AT_REMOVEDIR
)
os.
rmdir(name, dir_fd=rootfd
)
Availability: Unix.
...
...
Doc/whatsnew/3.3.rst
View file @
3eec12b3
This diff is collapsed.
Click to expand it.
Lib/gzip.py
View file @
3eec12b3
...
...
@@ -413,6 +413,8 @@ class GzipFile(io.BufferedIOBase):
if
self
.
fileobj
is
None
:
return
b''
try
:
# Ensure that we don't return b"" if we haven't reached EOF.
while
self
.
extrasize
==
0
:
# 1024 is the same buffering heuristic used in read()
self
.
_read
(
max
(
n
,
1024
))
except
EOFError
:
...
...
Lib/ipaddress.py
View file @
3eec12b3
This diff is collapsed.
Click to expand it.
Lib/test/test_httpservers.py
View file @
3eec12b3
...
...
@@ -313,6 +313,8 @@ class CGIHTTPServerTestCase(BaseTestCase):
class
request_handler
(
NoLogRequestHandler
,
CGIHTTPRequestHandler
):
pass
linesep
=
os
.
linesep
.
encode
(
'ascii'
)
def
setUp
(
self
):
BaseTestCase
.
setUp
(
self
)
self
.
cwd
=
os
.
getcwd
()
...
...
@@ -410,7 +412,7 @@ class CGIHTTPServerTestCase(BaseTestCase):
def
test_headers_and_content
(
self
):
res
=
self
.
request
(
'/cgi-bin/file1.py'
)
self
.
assertEqual
((
b'Hello World
\
n
'
,
'text/html'
,
200
),
self
.
assertEqual
((
b'Hello World
'
+
self
.
linesep
,
'text/html'
,
200
),
(
res
.
read
(),
res
.
getheader
(
'Content-type'
),
res
.
status
))
def
test_post
(
self
):
...
...
@@ -419,7 +421,7 @@ class CGIHTTPServerTestCase(BaseTestCase):
headers
=
{
'Content-type'
:
'application/x-www-form-urlencoded'
}
res
=
self
.
request
(
'/cgi-bin/file2.py'
,
'POST'
,
params
,
headers
)
self
.
assertEqual
(
res
.
read
(),
b'1, python, 123456
\
n
'
)
self
.
assertEqual
(
res
.
read
(),
b'1, python, 123456
'
+
self
.
linesep
)
def
test_invaliduri
(
self
):
res
=
self
.
request
(
'/cgi-bin/invalid'
)
...
...
@@ -430,20 +432,20 @@ class CGIHTTPServerTestCase(BaseTestCase):
headers
=
{
b'Authorization'
:
b'Basic '
+
base64
.
b64encode
(
b'username:pass'
)}
res
=
self
.
request
(
'/cgi-bin/file1.py'
,
'GET'
,
headers
=
headers
)
self
.
assertEqual
((
b'Hello World
\
n
'
,
'text/html'
,
200
),
self
.
assertEqual
((
b'Hello World
'
+
self
.
linesep
,
'text/html'
,
200
),
(
res
.
read
(),
res
.
getheader
(
'Content-type'
),
res
.
status
))
def
test_no_leading_slash
(
self
):
# http://bugs.python.org/issue2254
res
=
self
.
request
(
'cgi-bin/file1.py'
)
self
.
assertEqual
((
b'Hello World
\
n
'
,
'text/html'
,
200
),
self
.
assertEqual
((
b'Hello World
'
+
self
.
linesep
,
'text/html'
,
200
),
(
res
.
read
(),
res
.
getheader
(
'Content-type'
),
res
.
status
))
def
test_os_environ_is_not_altered
(
self
):
signature
=
"Test CGI Server"
os
.
environ
[
'SERVER_SOFTWARE'
]
=
signature
res
=
self
.
request
(
'/cgi-bin/file1.py'
)
self
.
assertEqual
((
b'Hello World
\
n
'
,
'text/html'
,
200
),
self
.
assertEqual
((
b'Hello World
'
+
self
.
linesep
,
'text/html'
,
200
),
(
res
.
read
(),
res
.
getheader
(
'Content-type'
),
res
.
status
))
self
.
assertEqual
(
os
.
environ
[
'SERVER_SOFTWARE'
],
signature
)
...
...
Lib/test/test_ipaddress.py
View file @
3eec12b3
...
...
@@ -7,6 +7,7 @@
import
unittest
import
re
import
contextlib
import
operator
import
ipaddress
class
BaseTestCase
(
unittest
.
TestCase
):
...
...
@@ -72,6 +73,14 @@ class CommonTestMixin:
with
self
.
assertAddressError
(
re
.
escape
(
repr
(
"1.0"
))):
self
.
factory
(
1.0
)
def
test_not_an_index_issue15559
(
self
):
# Implementing __index__ makes for a very nasty interaction with the
# bytes constructor. Thus, we disallow implicit use as an integer
self
.
assertRaises
(
TypeError
,
operator
.
index
,
self
.
factory
(
1
))
self
.
assertRaises
(
TypeError
,
hex
,
self
.
factory
(
1
))
self
.
assertRaises
(
TypeError
,
bytes
,
self
.
factory
(
1
))
class
CommonTestMixin_v4
(
CommonTestMixin
):
def
test_leading_zeros
(
self
):
...
...
@@ -599,7 +608,6 @@ class IpaddrUnitTest(unittest.TestCase):
self
.
assertEqual
(
first
,
last
)
self
.
assertEqual
(
128
,
ipaddress
.
_count_righthand_zero_bits
(
0
,
128
))
self
.
assertEqual
(
"IPv4Network('1.2.3.0/24')"
,
repr
(
self
.
ipv4_network
))
self
.
assertEqual
(
'0x1020318'
,
hex
(
self
.
ipv4_network
))
def
testMissingAddressVersion
(
self
):
class
Broken
(
ipaddress
.
_BaseAddress
):
...
...
@@ -639,8 +647,8 @@ class IpaddrUnitTest(unittest.TestCase):
ipv4
=
ipaddress
.
ip_network
(
'1.2.3.4'
)
ipv6
=
ipaddress
.
ip_network
(
'2001:658:22a:cafe:200:0:0:1'
)
self
.
assertEqual
(
ipv4
,
ipaddress
.
ip_network
(
int
(
ipv4
)))
self
.
assertEqual
(
ipv6
,
ipaddress
.
ip_network
(
int
(
ipv6
)))
self
.
assertEqual
(
ipv4
,
ipaddress
.
ip_network
(
int
(
ipv4
.
network_address
)))
self
.
assertEqual
(
ipv6
,
ipaddress
.
ip_network
(
int
(
ipv6
.
network_address
)))
v6_int
=
42540616829182469433547762482097946625
self
.
assertEqual
(
self
.
ipv6_interface
.
_ip
,
...
...
@@ -723,8 +731,8 @@ class IpaddrUnitTest(unittest.TestCase):
'2001:658:22a:cafe:ffff:ffff:ffff:ffff'
)
def
testGetPrefixlen
(
self
):
self
.
assertEqual
(
self
.
ipv4_interface
.
prefixlen
,
24
)
self
.
assertEqual
(
self
.
ipv6_interface
.
prefixlen
,
64
)
self
.
assertEqual
(
self
.
ipv4_interface
.
network
.
prefixlen
,
24
)
self
.
assertEqual
(
self
.
ipv6_interface
.
network
.
prefixlen
,
64
)
def
testGetSupernet
(
self
):
self
.
assertEqual
(
self
.
ipv4_network
.
supernet
().
prefixlen
,
23
)
...
...
@@ -1545,13 +1553,6 @@ class IpaddrUnitTest(unittest.TestCase):
self
.
assertEqual
(
42540616829182469433547762482097946625
,
int
(
self
.
ipv6_address
))
def
testHexRepresentation
(
self
):
self
.
assertEqual
(
hex
(
0x1020304
),
hex
(
self
.
ipv4_address
))
self
.
assertEqual
(
hex
(
0x20010658022ACAFE0200000000000001
),
hex
(
self
.
ipv6_address
))
def
testForceVersion
(
self
):
self
.
assertEqual
(
ipaddress
.
ip_network
(
1
).
version
,
4
)
self
.
assertEqual
(
ipaddress
.
IPv6Network
(
1
).
version
,
6
)
...
...
Misc/NEWS
View file @
3eec12b3
...
...
@@ -77,8 +77,12 @@ Core and Builtins
Library
-------
-
Issue
#
15546
:
Fix
handling
of
pathological
input
data
in
the
read1
()
method
of
the
BZ2File
,
GzipFile
and
LZMAFile
classes
.
-
Issue
#
15559
:
To
avoid
a
problematic
failure
mode
when
passed
to
the
bytes
constructor
,
objects
in
the
ipaddress
module
no
longer
implement
__index__
(
they
still
implement
__int__
as
appropriate
)
-
Issue
#
15546
:
Fix
handling
of
pathological
input
data
in
the
peek
()
and
read1
()
methods
of
the
BZ2File
,
GzipFile
and
LZMAFile
classes
.
-
Issue
#
13052
:
Fix
IDLE
crashing
when
replace
string
in
Search
/
Replace
dialog
ended
with
'\'
.
Patch
by
Roger
Serwy
.
...
...
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