[issue34102] local variable 'parts' referenced before assignment in feedparser in email module

2018-07-13 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

An exception is not a crash.  An intended exception is not even a bug.  A bug 
is a discrepancy between behavior and doc.  In this case, 
email.parser.Feedparser is imported from email.feedparser. Its doc
https://docs.python.org/2.7/library/email.parser.html#feedparser-api
says
"feed(data)
Feed the FeedParser some more data. data should be a string containing one 
or more lines."
In addition, html.parser.HTMLParser.feed(data) say "data must be str."

For either, behavior upon passing anything else is undefined.  Defining the 
behavior for None, and defining it to be 'return something' rather than 'raise 
something', would be an enhancement.  Such enhancements are only added, if 
deemed desirable, in future versions.

(Note: I recommend against resubmitting this for 3.8.  Masking bugs in 3rd 
party code is contrary to policy.  There would have to be a positive use-case 
of benefit large enough to multiple users to overcome the masking deficit.)

--
nosy: +terry.reedy
resolution:  -> not a bug
stage: patch review -> resolved
status: open -> closed
type: crash -> enhancement

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34102] local variable 'parts' referenced before assignment in feedparser in email module

2018-07-12 Thread R. David Murray


R. David Murray  added the comment:

This appears to be a bug in pip or the ansible-lint package, similar, and 
possibly identical, to issue 31361.  I believe None is being passed in as the 
argument to feed_parser.feed, which is an invalid use of that API and so 
correctly results in an error.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34102] local variable 'parts' referenced before assignment in feedparser in email module

2018-07-12 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Thanks @sshnaidm. The patch makes sense. Can you add a test case for this that 
fails without the patch? I have tried `pip install ansible-lint` and it works 
fine for me in Python 2.7.

I think a NEWS entry will help too : 
https://devguide.python.org/committing/#what-s-new-and-news-entries 

Thanks

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34102] local variable 'parts' referenced before assignment in feedparser in email module

2018-07-12 Thread Sagi (Sergey) Shnaidman


Sagi (Sergey) Shnaidman  added the comment:

@xtreak , sorry, you're right, I pasted a wrong traceback.
This is original traceback:

Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
  File "/usr/lib/python2.7/site-packages/pip/commands/install.py", line 346, in 
run
requirement_set.prepare_files(finder)
  File "/usr/lib/python2.7/site-packages/pip/req/req_set.py", line 380, in 
prepare_files
ignore_dependencies=self.ignore_dependencies))
  File "/usr/lib/python2.7/site-packages/pip/req/req_set.py", line 666, in 
_prepare_file
check_dist_requires_python(dist)
  File "/usr/lib/python2.7/site-packages/pip/utils/packaging.py", line 48, in 
check_dist_requires_python
feed_parser.feed(metadata)
  File "/usr/lib64/python2.7/email/feedparser.py", line 177, in feed
self._input.push(data)
  File "/usr/lib64/python2.7/email/feedparser.py", line 99, in push
parts = data.splitlines(True)
AttributeError: 'NoneType' object has no attribute 'splitlines'


And I pasted by mistake the one I used to debug.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34102] local variable 'parts' referenced before assignment in feedparser in email module

2018-07-12 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Hi,

I couldn't see the print statement in Lib/email/feedparser.py with latest 2.7 
branch and also `git log -p Lib/email/feedparser.py | grep print` doesn't 
return me anything. `pip install ansible-lint` also works fine with Python 2.7. 
I think this statement was added by mistake for debugging by the developer 
before `parts = data.splitlines(True)`. Can you please point me to the commit 
where the print statement was added or a test case to reproduce this?

Thanks

--
nosy: +xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34102] local variable 'parts' referenced before assignment in feedparser in email module

2018-07-12 Thread Sagi (Sergey) Shnaidman


Change by Sagi (Sergey) Shnaidman :


--
keywords: +patch
pull_requests: +7800
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34102] local variable 'parts' referenced before assignment in feedparser in email module

2018-07-12 Thread Sagi (Sergey) Shnaidman


New submission from Sagi (Sergey) Shnaidman :

sudo pip install ansible-lint
Requirement already satisfied: ansible-lint in /usr/lib/python2.7/site-packages 
(3.4.21)
Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/pip/_internal/basecommand.py", line 
228, in main
status = self.run(options, args)
  File "/usr/lib/python2.7/site-packages/pip/_internal/commands/install.py", 
line 291, in run
resolver.resolve(requirement_set)
  File "/usr/lib/python2.7/site-packages/pip/_internal/resolve.py", line 103, 
in resolve
self._resolve_one(requirement_set, req)
  File "/usr/lib/python2.7/site-packages/pip/_internal/resolve.py", line 262, 
in _resolve_one
check_dist_requires_python(dist)
  File "/usr/lib/python2.7/site-packages/pip/_internal/utils/packaging.py", 
line 46, in check_dist_requires_python
feed_parser.feed(metadata)
  File "/usr/lib64/python2.7/email/feedparser.py", line 178, in feed
self._input.push(data)
  File "/usr/lib64/python2.7/email/feedparser.py", line 99, in push
print(parts)
UnboundLocalError: local variable 'parts' referenced before assignment

pip2 --version
pip 10.0.1 from /usr/lib/python2.7/site-packages/pip (python 2.7)

--
components: email
messages: 321544
nosy: barry, r.david.murray, sshnaidm
priority: normal
severity: normal
status: open
title: local variable 'parts' referenced before assignment in feedparser in 
email module
type: crash
versions: Python 2.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com