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
4103bc09
Commit
4103bc09
authored
Nov 03, 2010
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #10281: nntplib now returns None for absent fields in the OVER/XOVER
response, instead of raising an exception.
parent
33d144aa
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
4 deletions
+35
-4
Doc/library/nntplib.rst
Doc/library/nntplib.rst
+2
-0
Lib/nntplib.py
Lib/nntplib.py
+4
-3
Lib/test/test_nntplib.py
Lib/test/test_nntplib.py
+26
-1
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/nntplib.rst
View file @
4103bc09
...
...
@@ -252,6 +252,8 @@ response indicates an error, the method raises one of the above exceptions.
(including headers and body)
* the ``:lines`` metadata: the number of lines in the article body
The value of each item is either a string, or :const:`None` if not present.
It is advisable to use the :func:`decode_header` function on header
values when they may contain non-ASCII characters::
...
...
Lib/nntplib.py
View file @
4103bc09
...
...
@@ -205,11 +205,12 @@ def _parse_overview(lines, fmt, data_process_func=None):
is_metadata
=
field_name
.
startswith
(
':'
)
if
i
>=
n_defaults
and
not
is_metadata
:
# Non-default header names are included in full in the response
h
=
field_name
+
":"
if
token
[:
len
(
h
)].
lower
()
!=
h
:
# (unless the field is totally empty)
h
=
field_name
+
": "
if
token
and
token
[:
len
(
h
)].
lower
()
!=
h
:
raise
NNTPDataError
(
"OVER/XOVER response doesn't include "
"names of additional headers"
)
token
=
token
[
len
(
h
):]
.
lstrip
(
" "
)
token
=
token
[
len
(
h
):]
if
token
else
None
fields
[
fmt
[
i
]]
=
token
overview
.
append
((
article_number
,
fields
))
return
overview
...
...
Lib/test/test_nntplib.py
View file @
4103bc09
...
...
@@ -457,7 +457,7 @@ class NNTPv1Handler:
"
\
t
Thu, 22 Jul 2010 09:14:14 -0400"
"
\
t
<A29863FA-F388-40C3-AA25-0FD06B09B5BF@gmail.com>"
"
\
t
\
t
6683
\
t
16"
"
\
t
Xref: news.gmane.org gmane.comp.python.authors:58
"
"
\
t
"
"
\
n
"
# An UTF-8 overview line from fr.comp.lang.python
"59
\
t
Re: Message d'erreur incompréhensible (par moi)"
...
...
@@ -824,6 +824,8 @@ class NNTPv1v2TestsMixin:
":lines"
:
"16"
,
"xref"
:
"news.gmane.org gmane.comp.python.authors:57"
})
art_num
,
over
=
overviews
[
1
]
self
.
assertEqual
(
over
[
"xref"
],
None
)
art_num
,
over
=
overviews
[
2
]
self
.
assertEqual
(
over
[
"subject"
],
"Re: Message d'erreur incompréhensible (par moi)"
)
...
...
@@ -1028,6 +1030,29 @@ class MiscTests(unittest.TestCase):
':lines'
:
'17'
,
'xref'
:
'news.example.com misc.test:3000363'
,
})
# Second example; here the "Xref" field is totally absent (including
# the header name) and comes out as None
lines
=
[
'3000234
\
t
I am just a test article
\
t
"Demo User" '
'<nobody@example.com>
\
t
6 Oct 1998 04:38:40 -0500
\
t
'
'<45223423@example.com>
\
t
<45454@example.net>
\
t
1234
\
t
'
'17
\
t
\
t
'
,
]
overview
=
nntplib
.
_parse_overview
(
lines
,
fmt
)
(
art_num
,
fields
),
=
overview
self
.
assertEqual
(
fields
[
'xref'
],
None
)
# Third example; the "Xref" is an empty string, while "references"
# is a single space.
lines
=
[
'3000234
\
t
I am just a test article
\
t
"Demo User" '
'<nobody@example.com>
\
t
6 Oct 1998 04:38:40 -0500
\
t
'
'<45223423@example.com>
\
t
\
t
1234
\
t
'
'17
\
t
Xref:
\
t
'
,
]
overview
=
nntplib
.
_parse_overview
(
lines
,
fmt
)
(
art_num
,
fields
),
=
overview
self
.
assertEqual
(
fields
[
'references'
],
' '
)
self
.
assertEqual
(
fields
[
'xref'
],
''
)
def
test_parse_datetime
(
self
):
def
gives
(
a
,
b
,
*
c
):
...
...
Misc/NEWS
View file @
4103bc09
...
...
@@ -59,6 +59,9 @@ Core and Builtins
Library
-------
- Issue #10281: nntplib now returns None for absent fields in the OVER/XOVER
response, instead of raising an exception.
- wsgiref now implements and validates PEP 3333, rather than an experimental
extension of PEP 333. (Note: earlier versions of Python 3.x may have
incorrectly validated some non-compliant applications as WSGI compliant;
...
...
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