[issue17646] traceback.py has a lot of code duplication

2013-04-29 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 84cef4f1999a by Benjamin Peterson in branch 'default':
refactor traceback.py to reduce code duplication (closes #17646)
http://hg.python.org/cpython/rev/84cef4f1999a

--
nosy: +python-dev
resolution:  - fixed
stage:  - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17646
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17646] traceback.py has a lot of code duplication

2013-04-22 Thread Martin Morrison

Martin Morrison added the comment:

Attached another diff, which includes new test cases to cover all functions 
that weren't covered before - expect print_last. I couldn't see a way of 
getting sys.last_* set to test that function (it seems to require an unhandled 
exception). However, the function is a simple wrapper around print_exception, 
and I have tested it manually in the interactive interpreter.

--
Added file: http://bugs.python.org/file29975/issue17646-5.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17646
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17646] traceback.py has a lot of code duplication

2013-04-20 Thread Martin Morrison

Martin Morrison added the comment:

On 20/04/2013 03:54, Benjamin Peterson wrote:
 It would be great to have a test for that. :)

I was afraid you'd say that. ;-)

I'll look at adding test cases to cover the functions not currently
covered (seems most of the print functions aren't, and all of the
'stack' functions aren't).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17646
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17646] traceback.py has a lot of code duplication

2013-04-20 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Could print_exception() in Lib/idlelib/run.py reuse new traceback functions?

--
nosy: +serhiy.storchaka

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17646
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17646] traceback.py has a lot of code duplication

2013-04-20 Thread Martin Morrison

Martin Morrison added the comment:

On 20 Apr 2013, at 18:55, Serhiy Storchaka rep...@bugs.python.org wrote:
 Serhiy Storchaka added the comment:
 
 Could print_exception() in Lib/idlelib/run.py reuse new traceback functions?

Actually, cleaning up code like that in Idle and the code module and import.c 
was what I was aiming to solve when I stumbled upon the duplication in 
traceback.py - once this patch is in, I plan to raise a separate issue with my 
suggestion for that clean up.

To answer your question directly, the changes I've made here don't solve the 
problem, no. More invasive changes are required, which is why I raised this 
cleanup portion of my change separately (on the assumption this change alone 
wouldn't be controversial, but my wider change might be).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17646
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17646] traceback.py has a lot of code duplication

2013-04-19 Thread Martin Morrison

Martin Morrison added the comment:

How embarrassing - I guess that'll teach me to try to doctor the diff file. :-)

I've now regenerated the diff, and re-run all the testing, etc. Apologies for 
the churn.

--
Added file: http://bugs.python.org/file29943/issue17646-3.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17646
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17646] traceback.py has a lot of code duplication

2013-04-19 Thread Benjamin Peterson

Benjamin Peterson added the comment:

Also, this patch seems to break test_zipimport.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17646
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17646] traceback.py has a lot of code duplication

2013-04-19 Thread Martin Morrison

Martin Morrison added the comment:

print_tb() wasn't passing the file argument through to print_list() - now 
fixed. I also verified none of the other functions had a similar bug.

--
Added file: http://bugs.python.org/file29944/issue17646-4.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17646
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17646] traceback.py has a lot of code duplication

2013-04-19 Thread Benjamin Peterson

Benjamin Peterson added the comment:

It would be great to have a test for that. :)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17646
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17646] traceback.py has a lot of code duplication

2013-04-18 Thread Benjamin Peterson

Benjamin Peterson added the comment:

Okay. Will you upload the latest version?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17646
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17646] traceback.py has a lot of code duplication

2013-04-18 Thread Martin Morrison

Martin Morrison added the comment:

Latest upload has all of the agreed markups from the review.

--
Added file: http://bugs.python.org/file29929/issue17646-2.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17646
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17646] traceback.py has a lot of code duplication

2013-04-18 Thread Benjamin Peterson

Benjamin Peterson added the comment:

What's this f_invisible thing?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17646
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17646] traceback.py has a lot of code duplication

2013-04-18 Thread Martin Morrison

Changes by Martin Morrison m...@ensoft.co.uk:


Removed file: http://bugs.python.org/file29929/issue17646-2.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17646
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17646] traceback.py has a lot of code duplication

2013-04-18 Thread Martin Morrison

Martin Morrison added the comment:

Sorry, that is an unrelated change I was experimenting with, which I 
accidentally forgot to take out.

Please see the new uploaded diff.

--
Added file: http://bugs.python.org/file29933/issue17646-2.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17646
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17646] traceback.py has a lot of code duplication

2013-04-18 Thread Benjamin Peterson

Benjamin Peterson added the comment:

patching file Lib/traceback.py
patch:  malformed patch at line 94: @@ -50,25 +90,7 @@

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17646
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17646] traceback.py has a lot of code duplication

2013-04-16 Thread Benjamin Peterson

Benjamin Peterson added the comment:

The other patch author hasn't updated his patch, so this issue can just 
superseded the other one.

I uploaded a few review comments.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17646
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17646] traceback.py has a lot of code duplication

2013-04-06 Thread Martin Morrison

New submission from Martin Morrison:

traceback.py contains a lot of code duplication, which makes it fragile in the 
face of changes (i.e. special cases) to the stack/traceback output (I am 
separately working on just such a change).

The attached patch refactors the code to reduce to a single function for each 
bit of logic, wrapped by the various existing APIs. The new helper functions 
are refactored as generators so as not to create unnecessary transient lists 
(not that stacks usually get very big anyway).

I've fully tested the replacement module, and it passes all the traceback tests 
in the standard suite.

--
components: Library (Lib)
files: traceback.diff
keywords: patch
messages: 186142
nosy: isoschiz
priority: normal
severity: normal
status: open
title: traceback.py has a lot of code duplication
type: enhancement
versions: Python 3.4
Added file: http://bugs.python.org/file29692/traceback.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17646
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17646] traceback.py has a lot of code duplication

2013-04-06 Thread R. David Murray

Changes by R. David Murray rdmur...@bitdance.com:


--
nosy: +r.david.murray

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17646
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17646] traceback.py has a lot of code duplication

2013-04-06 Thread Benjamin Peterson

Benjamin Peterson added the comment:

How much does this overlap with #17491?

--
nosy: +benjamin.peterson

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17646
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17646] traceback.py has a lot of code duplication

2013-04-06 Thread Martin Morrison

Martin Morrison added the comment:

I hadn't spotted that one!

My refactor goes further (consolidates all duplicates, not just the tb ones), 
is implemented the way you suggested therein (print in terms of extract), and 
is more efficient in that it uses generators for all intermediate iterators. 

However, I'm happy to either attach my diff to that issue, refactor mine in 
terms of that one, or whatever you think is best.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17646
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com