Ticket #4999 enhancement closed fixed

Opened 2 years ago

Last modified 9 months ago

replace call to functions from the string module in the python module

Reported by: nueces Owned by: thijs
Priority: normal Milestone: Python-3.x
Component: core Keywords: py3k
Cc: Branch: branches/str-methods-python-4999-2
Author: nueces, thijs Launchpad Bug:

Description

To make the port to python 3k more easy, I'm replacing all the calls to functions from the string module, for their equivalent from the str type object or calling directly to the built-in method of the string variable.

Attachments

python.patch Download (5.4 KB) - added by nueces 2 years ago.
patch

Change History

Changed 2 years ago by nueces

patch

1

  Changed 2 years ago by nueces

  • keywords py3k added; py3k, removed

2

  Changed 2 years ago by lvh

  • branch set to branches/str-methods-python-4999
  • branch_author set to lvh

(In [31458]) Branching to 'str-methods-python-4999'

3

  Changed 2 years ago by lvh

  • status changed from new to assigned
  • owner set to lvh

Patch looks clean, waiting for buildbot to come back clean:

http://twistedmatrix.com/trac/raw-attachment/ticket/4999/python.patch

4

  Changed 2 years ago by lvh

  • keywords review removed

Whoops! That was obviously the wrong link. I meant this:

 http://buildbot.twistedmatrix.com/boxes-supported?branch=/branches/str-methods-python-4999

... which looks clean except for an unrelated IOCP failure.

Added to my merge queue.

Thanks as always for your patch!

5

  Changed 2 years ago by exarkun

This patch modifies untested code.

6

  Changed 2 years ago by lvh

  • status changed from assigned to new
  • owner changed from lvh to nueces

What JP said. If you don't feel like adding a test, please unassign yourself (== assign to the empty item at the top of the list), by the way :)

7

  Changed 19 months ago by thijs

  • milestone set to Python-3.x

8

  Changed 10 months ago by thijs

  • owner nueces deleted

9

  Changed 10 months ago by thijs

  • branch changed from branches/str-methods-python-4999 to branches/str-methods-python-4999-2
  • branch_author changed from lvh to thijs, lvh

(In [35057]) Branching to 'str-methods-python-4999-2'

10

  Changed 10 months ago by thijs

(In [35059]) replace string methods in t.python, refs #4999

11

  Changed 10 months ago by thijs

  • keywords py3k, review added; py3k removed
  • branch_author changed from thijs, lvh to nueces, thijs

Replaced the string methos and added some new tests for the code that was changed but not covered.  Build results.

12

  Changed 10 months ago by vperic

  • owner set to thijs
  • keywords py3k added; py3k, review removed

Hmm, this overlaps with my patch at #5830 (make test_text.py pass in py3). As far as that module is concerne, the changes are the same (though I had some others, unrelated to the string module) but the tests are different. In general, I think your tests are a bit better - the problem is in test_dict - the ordering of elements in a dictionary is not cannonical so I believe it *will* fail on some architecture combination. In my patch, I tested just a single element dict, which will always work but provides less coverage (though it did cover all the changed lines so it was technically correct). Also, in the LineTests class, you might want to consider adding some assertFalse's, though I don't think it's really necessary.

Another note, (and I've been bitten by this myself), apparently Trac separates keywords with spaces, not commas, so you should use "py3k review" instead of "py3k, review". I'm also not sure what's the point of the keyword, especially when we have the milestone, so I haven't even been using it lately.

Anyway, please fix test_dict and then I'll check if all changed lines are covered (though I think they are). Consider this an official review. :)

13

  Changed 10 months ago by thijs

(In [35080]) address review comments. refs #4999

14

  Changed 10 months ago by thijs

  • keywords review added
  • owner thijs deleted

Thanks for the review. It's unfortunate the tickets do slightly overlap but the part that was changed for #5830 related to the string method was designated for this ticket (and maybe should've been fixed first, which were about to do :) Landing this ticket will only make the other ticket easier to review and fix.

 Build results.

15

  Changed 10 months ago by itamar

  • keywords review removed
  • owner set to thijs
  1. Drop the changes to twisted.python.hook, they're unrelated to this branch.
  2. LineTest needs a docstring.
  3. In docstrings of test methods, rather than saying "X supports Y", you should explain what X's behavior is. What is stringyString supposed to do to tuples?

Other than that it looks good, so once above are fixed and buildbot is happy it should be merged.

16

  Changed 10 months ago by vperic

I think you misunderstood my comment about test_dict - any dict with more than 1 key-value pair (and it now has two) can be a problem. I'm referring to this particular line from the documentation:

"CPython implementation detail: Keys and values are listed in an arbitrary order which is non-random, varies across Python implementations, and depends on the dictionary’s history of insertions and deletions."

17

follow-up: ↓ 19   Changed 10 months ago by itamar

Ah, yes. You shouldn't assume any particular order of dictionary items, as test_dict currently does. So that'd need to be fixed.

18

  Changed 10 months ago by thijs

(In [35147]) address review comments, refs #4999

19

in reply to: ↑ 17   Changed 10 months ago by thijs

  • status changed from new to assigned

Replying to itamar:

Ah, yes. You shouldn't assume any particular order of dictionary items, as test_dict currently does. So that'd need to be fixed.

Fixed.

Replying to itamar:

1. Drop the changes to twisted.python.hook, they're unrelated to this branch.

I reverted the coding standard stuff and left the string import change in there

1. LineTest needs a docstring.

Fixed.

1. In docstrings of test methods, rather than saying "X supports Y", you should explain what X's behavior is. What is stringyString supposed to do to tuples?

Fixed.

Other than that it looks good, so once above are fixed and buildbot is happy it should be merged.

 Build results.

20

  Changed 9 months ago by thijs

  • status changed from assigned to closed
  • resolution set to fixed

(In [35152]) Merge str-methods-python-4999-2: Replaced calls to functions from the string module in twisted.python.

Author: nueces, thijs Reviewer: lvh, exarkun, vperic, itamar Fixes: #4999

Note: See TracTickets for help on using tickets.