classification
Title: pyflakes: undefined "ctype" in 2 except blocks in the email module
Type: behavior Stage: resolved
Components: Versions: Python 3.4, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: barry, ezio.melotti, python-dev, r.david.murray, serhiy.storchaka, superluser, vstinner
Priority: normal Keywords: easy, patch

Created on 2014-03-19 10:49 by vstinner, last changed 2014-08-05 17:10 by vstinner. This issue is now closed.

Files
File name Uploaded Description Edit
undefined_ctypes.patch superluser, 2014-05-11 00:42 review
expose_bug.patch superluser, 2014-05-14 20:07 review
Messages (9)
msg214074 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-03-19 10:49
ctype is undefined in the two following blocks:

diff -r 72889bf8531d Lib/email/_header_value_parser.py
--- a/Lib/email/_header_value_parser.py Tue Mar 18 13:21:29 2014 +0100
+++ b/Lib/email/_header_value_parser.py Wed Mar 19 11:47:56 2014 +0100
@@ -2897,6 +2897,7 @@ def parse_content_disposition_header(val
     try:
         token, value = get_token(value)
     except errors.HeaderParseError:
+        # FIXME: ctype: undefined name
         ctype.defects.append(errors.InvalidHeaderDefect(
             "Expected content disposition but found {!r}".format(value)))
         _find_mime_parameters(disp_header, value)
@@ -2928,6 +2929,7 @@ def parse_content_transfer_encoding_head
     try:
         token, value = get_token(value)
     except errors.HeaderParseError:
+        # FIXME: ctype: undefined name
         ctype.defects.append(errors.InvalidHeaderDefect(
             "Expected content trnasfer encoding but found {!r}".format(value)))
     else:
msg218243 - (view) Author: Rose Ames (superluser) * Date: 2014-05-11 00:42
It looks like these are just typos, recording defects to ctype objects when it should be disp_header and cte_header?  Apologies if it's more complicated than that.
msg218428 - (view) Author: Rose Ames (superluser) * Date: 2014-05-13 10:23
This is my first attempt at contributing to python & I'd really appreciate some feedback :).  Should I have added a test to demonstrate the bug before trying to fix it?
msg218448 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-05-13 13:06
It doesn't really matter what order you do it in (though I prefer to write tests first, usually), but yes, we will want tests before we commit the fix.

I tried to be thorough in my testing, but obviously I missed some branches :(.
msg218452 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-05-13 13:25
I would prefer to see the patch applied if no test can be written.

The bug was not notified before.
msg218570 - (view) Author: Rose Ames (superluser) * Date: 2014-05-14 20:07
Thanks guys!  Added minimal tests necessary to expose the bug.
msg224726 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-08-04 14:23
New changeset 9ec2b429a607 by Ezio Melotti in branch '3.4':
#20977: fix undefined name in the email module.  Patch by Rose Ames.
http://hg.python.org/cpython/rev/9ec2b429a607

New changeset 944fc499ccd3 by Ezio Melotti in branch 'default':
#20977: merge with 3.4.
http://hg.python.org/cpython/rev/944fc499ccd3
msg224727 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2014-08-04 14:25
Fixed, thanks for the patch!
msg224862 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-08-05 17:10
Thanks for the fix.
History
Date User Action Args
2014-08-05 17:10:20vstinnersetmessages: + msg224862
2014-08-04 14:25:00ezio.melottisetstatus: open -> closed

versions: - Python 2.7
nosy: + ezio.melotti

messages: + msg224727
resolution: fixed
stage: needs patch -> resolved
2014-08-04 14:23:31python-devsetnosy: + python-dev
messages: + msg224726
2014-05-14 20:07:54superlusersetfiles: + expose_bug.patch

messages: + msg218570
2014-05-13 13:25:27vstinnersetmessages: + msg218452
2014-05-13 13:06:28r.david.murraysetmessages: + msg218448
2014-05-13 10:23:20superlusersetmessages: + msg218428
2014-05-11 00:42:57superlusersetfiles: + undefined_ctypes.patch

nosy: + superluser
messages: + msg218243

keywords: + patch
2014-04-20 22:40:26ezio.melottisetkeywords: + easy
type: behavior
stage: needs patch
2014-03-20 08:06:49vstinnersettitle: pyflakes: undefined "ctype" in 2 except blocks -> pyflakes: undefined "ctype" in 2 except blocks in the email module
2014-03-19 21:09:34serhiy.storchakasetnosy: + serhiy.storchaka

versions: + Python 2.7
2014-03-19 10:49:13vstinnercreate