Ticket #6066 enhancement new

Opened 8 months ago

Last modified 5 months ago

Create utility function for getting name of a function for use by __str__

Reported by: itamar Owned by: itamar
Priority: normal Milestone:
Component: core Keywords:
Cc: Branch: branches/functionname-6066
Author: itamarst Launchpad Bug:

Description

Various places in Twisted (LoopingCall, DelayedCall) have logic for getting a string representation of functions. This logic should be unified in a single utility function in twisted.python.reflect.

Attachments

6066.diff Download (3.5 KB) - added by borko 5 months ago.
diff v1
6066_v2.diff Download (5.6 KB) - added by borko 5 months ago.
diff 2

Change History

1

Changed 8 months ago by itamar

  • keywords easy added
  • milestone Python 3.3 Minimal deleted

2

Changed 5 months ago by borko

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

Changed 5 months ago by borko

diff v1

3

Changed 5 months ago by borko

  • keywords review added; easy removed

4

Changed 5 months ago by itamar

  • keywords review removed
  • status changed from assigned to new

Thanks for submitting this! It's very nice to get patches with tests.

  1. I will note that we're trying to get rid of _reflectpy3 (see #6183), but until then if you've added code to _reflectpy3 you should make sure it's publicly available from twisted.python.reflect (i.e. appears in __all__ in the latter module).
  2. The docstring for getFunctionName indicates it will return None, which is not the case.
  3. I would call the argument to getFunctionName something like function; Python doesn't have pointers.
  4. You need a test for the safe_repr() case, if I'm not mistaken.
  5. Your tests talk about the "second argument", but there is only one argument.

5

Changed 5 months ago by itamar

Please fix the above and resubmit.

Changed 5 months ago by borko

diff 2

6

Changed 5 months ago by borko

  • keywords review added

7

Changed 5 months ago by borko

Thx for fast answer! 1. Do we want to dispose of the reflectpy3 file by slowly porting all the code to reflectpy ? Or move it to other modules ?

8

Changed 5 months ago by itamar

  • owner borko deleted

We'll restore the code to its original home in reflect.py, using a slightly tricky procedure since we want to preserve version control history and pretend _reflectpy3.py never happened.

9

Changed 5 months ago by borko

second patch created. waiting for acceptance.

10

Changed 5 months ago by itamarst

  • branch set to branches/functionname-6066
  • branch_author set to itamarst

(In [36575]) Branching to 'functionname-6066'

11

Changed 5 months ago by itamar

  • keywords review removed
  • owner set to itamar

Looks good, just needs slightly better descriptions and a news file; I will do that and merge.

12

Changed 5 months ago by itamarst

(In [36601]) Apply patch, with some minor fixes. Refs #6066

Note: See TracTickets for help on using tickets.