diff --git a/twisted/internet/base.py b/twisted/internet/base.py
index 46e9217..5f10c6c 100644
|
a
|
b
|
|
| 176 | 176 | if self._str is not None: |
| 177 | 177 | return self._str |
| 178 | 178 | if hasattr(self, 'func'): |
| 179 | | # This code should be replaced by a utility function in reflect; |
| 180 | | # see ticket #6066: |
| 181 | | if hasattr(self.func, '__qualname__'): |
| 182 | | func = self.func.__qualname__ |
| 183 | | elif hasattr(self.func, '__name__'): |
| 184 | | func = self.func.func_name |
| 185 | | if hasattr(self.func, 'im_class'): |
| 186 | | func = self.func.im_class.__name__ + '.' + func |
| 187 | | else: |
| 188 | | func = reflect.safe_repr(self.func) |
| | 179 | func = reflect.getFunctionName(self.func) |
| 189 | 180 | else: |
| 190 | 181 | func = None |
| 191 | 182 | |
diff --git a/twisted/internet/task.py b/twisted/internet/task.py
index 6e7b908..11afa17 100644
|
a
|
b
|
|
| 244 | 244 | |
| 245 | 245 | |
| 246 | 246 | def __repr__(self): |
| 247 | | if hasattr(self.f, '__qualname__'): |
| 248 | | func = self.f.__qualname__ |
| 249 | | elif hasattr(self.f, '__name__'): |
| 250 | | func = self.f.__name__ |
| 251 | | if hasattr(self.f, 'im_class'): |
| 252 | | func = self.f.im_class.__name__ + '.' + func |
| 253 | | else: |
| 254 | | func = reflect.safe_repr(self.f) |
| 255 | | |
| 256 | 247 | return 'LoopingCall<%r>(%s, *%s, **%s)' % ( |
| 257 | | self.interval, func, reflect.safe_repr(self.a), |
| | 248 | self.interval, reflect.getFunctionName(self.f), reflect.safe_repr(self.a), |
| 258 | 249 | reflect.safe_repr(self.kw)) |
| 259 | 250 | |
| 260 | 251 | |
diff --git a/twisted/python/_reflectpy3.py b/twisted/python/_reflectpy3.py
index c0451e9..226bb20 100644
|
a
|
b
|
|
| 286 | 286 | return '<BROKEN CLASS AT 0x%x>' % unsignedID(c) |
| 287 | 287 | |
| 288 | 288 | |
| | 289 | def getFunctionName(funptr): |
| | 290 | """ |
| | 291 | Return name of the function passed |
| | 292 | |
| | 293 | @param funptr: Searched function. |
| | 294 | |
| | 295 | @return: Function name or None if it does not exist for passed object |
| | 296 | """ |
| | 297 | if hasattr( funptr , '__qualname__'): |
| | 298 | func = funptr.__qualname__ |
| | 299 | elif hasattr( funptr, '__name__'): |
| | 300 | func = funptr.func_name |
| | 301 | if hasattr(funptr, 'im_class'): |
| | 302 | func = funptr.im_class.__name__ + '.' + func |
| | 303 | else: |
| | 304 | func = safe_repr(funptr) |
| | 305 | return func |
| | 306 | |
| | 307 | |
| 289 | 308 | def _safeFormat(formatter, o): |
| 290 | 309 | """ |
| 291 | 310 | Helper function for L{safe_repr} and L{safe_str}. |
diff --git a/twisted/python/test/test_reflectpy3.py b/twisted/python/test/test_reflectpy3.py
index acd8f8d..8722b10 100644
|
a
|
b
|
|
| 350 | 350 | |
| 351 | 351 | |
| 352 | 352 | |
| | 353 | class GetFunctionNameTestCase(TestCase): |
| | 354 | """ |
| | 355 | Tests for L{getFunctionName}. |
| | 356 | """ |
| | 357 | |
| | 358 | def test_function(self): |
| | 359 | """ |
| | 360 | L{getFunctionName} should return function name passed as a second argument. |
| | 361 | """ |
| | 362 | self.assertEqual( |
| | 363 | reflect.getFunctionName(reflect.getFunctionName), |
| | 364 | "getFunctionName") |
| | 365 | |
| | 366 | def test_memberFunction(self): |
| | 367 | """ |
| | 368 | L{getFunctionName} should return fully qualified function name passed as a second argument. |
| | 369 | """ |
| | 370 | self.assertEqual( |
| | 371 | reflect.getFunctionName(self.test_memberFunction), |
| | 372 | "GetFunctionNameTestCase.test_memberFunction") |
| | 373 | |
| | 374 | |
| | 375 | |
| 353 | 376 | class Breakable(object): |
| 354 | 377 | |
| 355 | 378 | breakRepr = False |