[issue27397] email.message.Message.get_payload(decode=True) raises AssertionError that "should never happen"

2016-06-26 Thread Claudiu Saftoiu

New submission from Claudiu Saftoiu:

I'm processing Yahoo! Groups backup archives, and came across an email message 
which causes the `.get_payload(decode=True)` step to raise an AssertionError. 
Particularly, the following exception is raised in 
`lib/python3.5/email/_encoded_words.py`, line 124:

# This should never happen.
raise AssertionError("unexpected binascii.Error")

Attached is the file which, when run under Python 3.5.1, causes the exception 
to be raised.

--
components: Library (Lib)
files: bugreport.py
messages: 269346
nosy: Claudiu Saftoiu
priority: normal
severity: normal
status: open
title: email.message.Message.get_payload(decode=True) raises AssertionError 
that "should never happen"
type: crash
versions: Python 3.5
Added file: http://bugs.python.org/file43556/bugreport.py

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



[issue27397] email.message.Message.get_payload(decode=True) raises AssertionError that "should never happen"

2016-06-26 Thread Claudiu Saftoiu

Claudiu Saftoiu added the comment:

See attached another file with more test cases.

--
Added file: http://bugs.python.org/file43557/bugreport_moretests.py

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



[issue27565] Offer error context manager for code.interact

2016-07-18 Thread Claudiu Saftoiu

New submission from Claudiu Saftoiu:

When debugging code that raises unexpected exceptions, I often find myself 
doing this:

try:
some_code
except:
import code; code.interact(local=locals())
raise

My suggestion is a context manager to make this less verbose:

with code.interact_on_error():
some_code

The effect would be the same: if an exception is caught, `code.interact` is 
called with the locals of the function, and re-raised when `code.interact` ends.

--
components: Library (Lib)
messages: 270786
nosy: Claudiu Saftoiu
priority: normal
severity: normal
status: open
title: Offer error context manager for code.interact
type: enhancement

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



[issue27678] itertools.permutations/.combinations should have len

2016-08-04 Thread Claudiu Saftoiu

New submission from Claudiu Saftoiu:

Right now, itertools.permutations and itertools.combinations and 
itertools.product objects don't have a `len`. 

>>> len(itertools.combinations(range(10), 5))
Traceback (most recent call last):
  File "", line 1, in 
TypeError: object of type 'itertools.combinations' has no len()

I propose that a `len` be added to them, which computes (& caches) & returns 
the length. If the underlying iterator doesn't have a length, then they can 
raise a TypeError as they do now.

--
messages: 271952
nosy: Claudiu Saftoiu
priority: normal
severity: normal
status: open
title: itertools.permutations/.combinations should have len
type: enhancement
versions: Python 3.6

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



[issue27678] itertools.permutations/.combinations should have len

2016-08-04 Thread Claudiu Saftoiu

Claudiu Saftoiu added the comment:

Ahh, I see. In that case, if the object passed-in has a length, use that. If 
not, then raise TypeError. e.g. proposed behavior:

>>> len(itertool.combinations(range(10), 2))
45
>>> len(itertool.combinations(iter(range(10)), 2))
...
TypeError: itertools.combinations underlying object has no len()

--

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