Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

textwrap wordsep_re #41617

Closed
quarl mannequin opened this issue Feb 23, 2005 · 3 comments
Closed

textwrap wordsep_re #41617

quarl mannequin opened this issue Feb 23, 2005 · 3 comments
Labels
stdlib Python modules in the Lib dir

Comments

@quarl
Copy link
Mannequin

quarl mannequin commented Feb 23, 2005

BPO 1149508
Files
  • textwrap-numbers.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2005-03-05.02:58:32.000>
    created_at = <Date 2005-02-23.01:10:48.000>
    labels = ['library']
    title = 'textwrap wordsep_re'
    updated_at = <Date 2005-03-05.02:58:32.000>
    user = 'https://bugs.python.org/quarl'

    bugs.python.org fields:

    activity = <Date 2005-03-05.02:58:32.000>
    actor = 'gward'
    assignee = 'gward'
    closed = True
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2005-02-23.01:10:48.000>
    creator = 'quarl'
    dependencies = []
    files = ['6516']
    hgrepos = []
    issue_num = 1149508
    keywords = ['patch']
    message_count = 3.0
    messages = ['47844', '47845', '47846']
    nosy_count = 2.0
    nosy_names = ['gward', 'quarl']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue1149508'
    versions = ['Python 2.4']

    @quarl
    Copy link
    Mannequin Author

    quarl mannequin commented Feb 23, 2005

    The following patch makes textwrap not consider strings
    of numbers with dashes to be wrappable hyphenated words.

    For example, this code:
    print textwrap.fill('aaaaaaaaaa 2005-02-21', 18)
    previously produces:
    aaaaaaaaaa 2005-
    02-21

    but with patch:
    aaaaaaaaaa
    2005-02-21

    --- /usr/lib/python2.4/textwrap.py	2005-02-09
    04:02:11.000000000 -0800
    +++ /tmp/textwrap.py	2005-02-22 17:07:19.000000000 -0800
    @@ -79,7 +79,7 @@
         #   Hello/ /there/ /--/ /you/ /goof-/ball,/ /use/
    /the/ /-b/ /option!
         # (after stripping out empty strings).
         wordsep_re = re.compile(r'(\s+|'                 
    # any whitespace
    -                           
    r'[^\s\w]*\w{2,}-(?=\w{2,})|' # hyphenated words
    +                           
    r'[^\s\w]*\w+[a-zA-Z]-(?=\w+[a-zA-Z])|' # hyphenated words
                                
    r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))')   # em-dash
     
         # XXX this is not locale- or charset-aware --
    string.lowercase

    @quarl quarl mannequin closed this as completed Feb 23, 2005
    @quarl quarl mannequin assigned gward Feb 23, 2005
    @quarl quarl mannequin added the stdlib Python modules in the Lib dir label Feb 23, 2005
    @quarl quarl mannequin closed this as completed Feb 23, 2005
    @quarl quarl mannequin assigned gward Feb 23, 2005
    @quarl quarl mannequin added the stdlib Python modules in the Lib dir label Feb 23, 2005
    @quarl
    Copy link
    Mannequin Author

    quarl mannequin commented Feb 27, 2005

    Logged In: YES
    user_id=599526

    Assigned to gward as requested.

    The attached patch also contains an additional unit test
    that fails without this fix.

    To apply: cd Python-2.4 && patch -p6 < testwrap.patch

    @gward
    Copy link
    Mannequin

    gward mannequin commented Mar 5, 2005

    Logged In: YES
    user_id=14422

    Thank you! Checked in on release24-maint branch:
    Lib/textwrap.py rev 1.35.4.1
    Lib/test/test_textwrap.py,v rev 1.27.4.1

    Merged onto trunk:
    Lib/textwrap.py rev 1.37
    Lib/test/test_textwrap.py,v rev 1.28

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    0 participants