Changes by paul j3 ajipa...@gmail.com:
--
nosy: +paul.j3
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1859
___
___
Python-bugs-list mailing list
dani added the comment:
applied patches textwrap_2010-11-23.diff and issue1859_docs.diff
added line_break tests
--
nosy: +dbudinova
Added file: http://bugs.python.org/file34519/line_break_tests.patch
___
Python tracker rep...@bugs.python.org
Changes by Mark Lawrence breamore...@yahoo.co.uk:
--
nosy: -BreamoreBoy
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1859
___
___
Changes by Jesús Cea Avión j...@jcea.es:
--
nosy: +jcea
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1859
___
___
Python-bugs-list mailing list
Serhiy Storchaka added the comment:
I believe that the method of work with newlines is too application specific.
Someone may prefer empty line separated paragraphs, here is another recipe:
def wrap_paragraphs(text, width=70, **kwargs):
return [line for para in re.split(r'\n\s*\n', text)
Changes by R. David Murray rdmur...@bitdance.com:
--
nosy: +r.david.murray
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1859
___
___
Antoine Pitrou added the comment:
After discussing issue15510, I think this should probably be left as-is, or be
implemented in a separate function so as to avoid breaking compatibility.
--
nosy: +pitrou
___
Python tracker rep...@bugs.python.org
Chris Jerdonek added the comment:
After discussing issue15510, I think this should probably be left as-is, or
be implemented in a separate function so as to avoid breaking compatibility.
Note that this issue can be addressed without affecting backwards compatibility
in the documented
Chris Jerdonek added the comment:
Marking issue 15510 as a dependency because there is a behavioral issue in
existing use cases that affects how to proceed in this issue.
--
dependencies: +textwrap.wrap('') returns empty list
___
Python tracker
Chris Jerdonek added the comment:
In working on the patch for this issue, I also noticed that there is a minor
error in the documentation of the replace_whitespace attribute.
The docs say that string.whitespace is used, but the code uses a hard-coded
string and includes a comment explaining
Chris Jerdonek added the comment:
Sorry, that link should have been--
http://hg.python.org/cpython/file/1d811e1097ed/Lib/textwrap.py#l12
(hg.python.org seems to default to the 2.7 branch. I just filed an issue about
this.)
--
___
Python tracker
Chris Jerdonek added the comment:
If people are interested, I filed a new issue (issue 15492) about textwrap's
tab expansion that I noticed while working on this issue.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1859
Serhiy Storchaka storch...@gmail.com added the comment:
def wrap_paragraphs(text, width=70, **kwargs):
return [line for para in text.splitlines() for line in textwrap.wrap(para,
width, **kwargs) or ['']]
--
___
Python tracker
Chris Jerdonek chris.jerdo...@gmail.com added the comment:
Here is an even simpler failing test case:
from textwrap import wrap
wrap(a\nb, replace_whitespace=False)
['a\nb']
It should return--
['a', 'b']
I will start working on this issue by assembling formal test cases.
--
nosy:
Chris Jerdonek chris.jerdo...@gmail.com added the comment:
def wrap_paragraphs(text, width=70, **kwargs):
return [line for para in text.splitlines() for line in
textwrap.wrap(para, width, **kwargs)]
I just want to point out that, at least for the purposes of this issue, I don't
believe
Otto Kekäläinen o...@seravo.fi added the comment:
As a note to comments msg60038-msg60040, for anybody like me who ended up here
after Googling around on how to do wordwrap in Python:
The function textwrap in Python is for single strings/paragraphs only, and it
does not work as wordwrap
Otto Kekäläinen o...@seravo.fi added the comment:
In previous comment: (eg. Wordwrap in Python) - (wordwrap() in PHP)
Some examples of how this function works on text blocks:
Original text:
--
*Maksaako riippuvuus yksittäisestä ohjelmistoyritykstä Helsingille vuosittain
3,4 miljoonaa euroa?*
Serhiy Storchaka storch...@gmail.com added the comment:
Cooking recipe for Otto:
def wrap_paragraphs(text, width=70, **kwargs):
return [line for para in text.splitlines() for line in textwrap.wrap(para,
width, **kwargs)]
--
nosy: +storchaka
___
Phillip M. Feldman phillip.m.feld...@gmail.com added the comment:
I would like to unsubscribe from this thread, but haven't been able to
figure out how to do it.
Phillip
On Mon, Nov 22, 2010 at 11:50 PM, Georg Brandl rep...@bugs.python.orgwrote:
Georg Brandl ge...@python.org added the
Changes by Brian Curtin cur...@acm.org:
--
nosy: -phillip.m.feld...@gmail.com
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1859
___
___
Changes by Terry J. Reedy tjre...@udel.edu:
Removed file: http://bugs.python.org/file19785/unnamed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1859
___
Matthew Barnett pyt...@mrabarnett.plus.com added the comment:
textwrap_2010-11-23.diff is my attempt to provide a fix, if it's wanted/needed.
--
Added file: http://bugs.python.org/file19791/textwrap_2010-11-23.diff
___
Python tracker
Terry J. Reedy tjre...@udel.edu added the comment:
Doc patch applied to 3.2, 3.1, 2.7 in r86717, r86718, r86719
Jeremy Thurgood added to 3.2 Misc/ACKS in r86720.
(I know, I should have added this first before committing.)
I am leaving this open for a possible behavior patch.
Mathew: look at
Changes by Terry J. Reedy tjre...@udel.edu:
--
versions: -Python 2.7
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1859
___
___
Python-bugs-list
Tom Lynn tl...@users.sourceforge.net added the comment:
I've also been attempting to look into this and came up with an almost
identical patch, which is promising:
https://bitbucket.org/tlynn/issue1859/diff/textwrap.py?diff2=041c9deb90a2diff1=f2c093077fbf
I missed the wordsep_simple_re though.
Matthew Barnett pyt...@mrabarnett.plus.com added the comment:
I'd be interested in having a go if I knew what the desired behaviour was, ie
unit tests to confirm what was 'correct'.
How should it handle line breaks? Should it treat them like any other
whitespace as at present, should it
Terry J. Reedy tjre...@udel.edu added the comment:
Georg, if your comment means that you think that the doc patch is ready to
apply, as is, without testing with a doc build, then I will do so for all 3
versions.
Should there really be two blank lines after the note?
--
Georg Brandl ge...@python.org added the comment:
Yes, please do apply. You don't need to run a doc build for every small
change; of course it is nice if you do, but errors will be caught by the daily
build routine anyway and mailed to me.
As for the two blank lines: you'll see that the
Georg Brandl ge...@python.org added the comment:
+1 for applying the doc patch.
--
nosy: +georg.brandl
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1859
___
Jeremy Thurgood fir...@gmail.com added the comment:
The weird behaviour is caused by newlines being treated as normal whitespace
characters and not actually causing _wrap_chunks() to break the line. This
means that it builds lines of up to 'width' characters which may contain
newlines:
text
Jeremy Thurgood fir...@gmail.com added the comment:
Here's a doc patch for py3k. A similar patch for 2.7 (and other versions?)
might be a good idea.
--
keywords: +patch
Added file: http://bugs.python.org/file19676/issue1859_docs.diff
___
Python
Mark Lawrence breamore...@yahoo.co.uk added the comment:
Anyone interested in picking this up? I've tried and fell flat on my face :(
--
nosy: +BreamoreBoy
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1859
Mark Dickinson dicki...@gmail.com added the comment:
Thanks for the feedback, Greg!
I'm afraid I'm unassigning this; I don't have time for it right now, and
I'm not sure I'm the right person to do this anyway.
One problem that I was having when I looked at this: I don't think I
understand
Phillip M. Feldman pfeld...@verizon.net added the comment:
As a temporary workaround, you can use the `wrap` function in my strnum
module (http://pypi.python.org/pypi/strnum/2.4).
Phillip
--
nosy: +pfeld...@verizon.net
___
Python tracker
Mark Dickinson dicki...@gmail.com added the comment:
I notice that Greg Ward just resurfaced on the issue tracker (issue 6454).
:)
Greg, any comment on this issue?
--
nosy: +gward
stage: - test needed
type: behavior - feature request
versions: -Python 2.6, Python 3.1
Mark Dickinson dicki...@gmail.com added the comment:
The current patch is too simple: it fails if lines end with ' \n', for
example. The simplest way to make this work may be to put each '\n' into
its own chunk.
--
___
Python tracker
Greg Ward g...@gerg.ca added the comment:
Greg, any comment on this issue?
Yes, two:
1) textwrap does not handle paragraphs or paragraph breaks in any way.
That was a deliberate limitation to keep the code from getting any
hairier. People have complained about this in the past, and I have
Mark Dickinson dicki...@gmail.com added the comment:
I'll take a look.
--
assignee: - mark.dickinson
priority: - normal
versions: +Python 2.6, Python 2.7, Python 3.1, Python 3.2 -Python 2.4, Python
2.5
___
Python tracker rep...@bugs.python.org
Terry J. Reedy tjre...@udel.edu added the comment:
I agree that if newlines in the text are left in, they should reset the
characters in line count to 0 the same as inserted newlines.
--
nosy: +tjreedy
___
Python tracker rep...@bugs.python.org
Tom Lynn tl...@users.sourceforge.net added the comment:
This bug should be re-opened, since there is definitely a bug here.
I think the patch was incorrectly rejected.
If I can expand palfrey's example:
from textwrap import *
T = TextWrapper(replace_whitespace=False, width=75)
text = '''\
Guido van Rossum gu...@python.org added the comment:
I think the code originally wasn't meant to support this feature (honor
embedded newlines when replace_whitespace=False). I'm thinking that we
could add it though. Maybe Mark is interested in getting this into 2.7
and 3.2? I imagine it
Tom Parker added the comment:
Attaching a patch that corrects the issue (against python 2.4)
Added file: http://bugs.python.org/file9192/textwrap-fix.patch
__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1859
__
New submission from Tom Parker:
If a piece of text given to textwrap contains one or more \n, textwrap
does not break at that point. I would have expected \n characters to
cause forced breaks.
--
components: Library (Lib)
messages: 60026
nosy: palfrey
severity: minor
status: open
title:
Tom Parker added the comment:
If replace_whitespace in textwrap is set to False (True is default) then
there are newlines. Yes, if you haven't set this then the patch does
nothing (but that sounds sane to me)
The exact text was RadioTest TOSSIM stress tester by Tom Parker
[EMAIL
Mark Dickinson added the comment:
Could you give an example showing the unexpected behaviour, and
describing what behaviour you'd expect, please?
As far as I can tell, the patch has no effect on textwrap.wrap or
textwrap.fill, since any newlines have already been converted to spaces
by the
Guido van Rossum added the comment:
Mark, it looks like the replace_whitespace flag shouldn't be used with
input containing newlines.
__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1859
__
Mark Dickinson added the comment:
Is it worth double checking with Greg Ward that this behaviour really is
intentional?
__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1859
__
Tom Parker added the comment:
@Guido: Thanks for the suggestion, it fixes my immediate problem!
@Mark: Yup, that was exactly my issue. It took a while to figure out why
the heck it was ignoring my linebreaks, and then once I'd found
replace_whitespace it appeared to be doing the wrong thing to
Guido van Rossum added the comment:
The original behavior is intentional. Please don't attempt to fix it.
--
nosy: +gvanrossum
resolution: - rejected
status: open - closed
__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1859
Mark Dickinson added the comment:
For what it's worth, I think there is a legitimate complaint here, though it
was initially
unclear to me exactly what that complaint was. Consider the following:
from textwrap import *
T = TextWrapper(replace_whitespace=False, width=14)
for line in
Guido van Rossum added the comment:
Use .splitlines() to break the input into lines, wrap each line
separately, and join again?
__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1859
__
Guido van Rossum added the comment:
Good luck reaching him.
I'm pretty sure that the default behavior intentional *reflows* all
input text. Perhaps you can derive clues from reading the docs (which I
haven't)?
__
Tracker [EMAIL PROTECTED]
Tom Parker added the comment:
Is there any other way to do what I was trying to do then (both dynamic
wrapping for long segments + some static breaks)? Right now, the only
option I can think of is writing a textwrap.TextWrapper subclass that
implements my patch, and copying 70-ish lines of code
53 matches
Mail list logo