Opened 2 years ago

Closed 2 years ago

#5916 enhancement closed fixed (fixed)

Port twisted.python.deprecate to Python 3

Reported by: exarkun Owned by: exarkun
Priority: normal Milestone: Python 3.3 Minimal
Component: core Keywords:
Cc: Branch: branches/deprecate-python3-5916-3
(diff, github, buildbot, log)
Author: exarkun Launchpad Bug:

Description (last modified by exarkun)

This is needed by SynchronousTestCase to implement the assertWarns functionality. Specifically, trial uses:

  • deprecated
  • getDeprecationWarningString
  • warnAboutFunction
  • deprecatedModuleAttribute

However, the last two are only used to warn about deprecated functionality, so we can probably skip them and remove that deprecated functionality instead.

Change History (15)

comment:1 Changed 2 years ago by exarkun

  • Description modified (diff)

comment:2 Changed 2 years ago by exarkun

  • Author set to exarkun
  • Branch set to branches/deprecate-python3-5916-2

(In [35432]) Branching to 'deprecate-python3-5916-2'

comment:3 Changed 2 years ago by exarkun

  • Description modified (diff)

comment:4 Changed 2 years ago by exarkun

(In [35433]) Port some parts of twisted.python.deprecate that trial really wants

refs #5916

comment:5 Changed 2 years ago by exarkun

  • Keywords review added
  • Owner changed from exarkun to itamar
  1. Moved tests for deprecated and getVersionString and getDeprecationWarningString into twisted/python/test/test_deprecatepy3.py
  2. Changed some strings in those tests which depend on the module in which the code is defined.
  3. Changed one test using assertWarns to use warnings.catch_warnings instead.
  4. Moved implementation of those methods into twisted/python/_deprecatepy3.py
  5. Also moved _fullyQualifiedName and changed its method handling around a little to work with Python 3.3 changes (should really do this in a separate branch, but waiting for other reflect changes to land first).

Tested locally, but didn't force a build yet, buildbot is too busy.

comment:6 Changed 2 years ago by exarkun

(In [35442]) Filename can be pyc.
refs #5916

comment:7 Changed 2 years ago by exarkun

  • Branch changed from branches/deprecate-python3-5916-2 to branches/deprecate-python3-5916-3

(In [35443]) Branching to 'deprecate-python3-5916-3'

comment:8 Changed 2 years ago by exarkun

(In [35445]) Move the fullyQualifiedName tests into test_reflectpy3; adjust them to work in that position. Fix a couple more Python 3 incompatibilities in that function.

refs #5916

comment:9 Changed 2 years ago by exarkun

Okay, since #5914 landed, I did the fullyQualifiedName tests properly. In addition to the list of things I mentioned above, the branch now moves the fullyQualifiedName tests into test_reflectpy3.py, adjusts them to use available names (it imports a lot of random extra names; the specific names are not relevant, just the kind of objects they refer to), and fixes another couple bugs in the fullyQualifiedName port.

comment:11 Changed 2 years ago by exarkun

(In [35447]) Either side can be a pyc

refs #5916

comment:12 Changed 2 years ago by itamar

  • Keywords review removed
  • Owner changed from itamar to exarkun
  1. The test that compares reflect to "twisted.python._reflectpy3" and says it's a trick is bad. Either compare _reflectpy3 (you can reimport it) or just do compat.
  2. I don't understand the line at top of test_reflectpy3 module about how the function should be imported from reflect.
  3. Add __future__ imports.

Please fix the above, then merge.

comment:13 Changed 2 years ago by exarkun

(In [35457]) Improve the comment about the _fullyQualifiedName import. Also remove the tricky test, which is redundant anyway.

refs #5916

comment:14 Changed 2 years ago by exarkun

(In [35458]) Add future imports

refs #5916

comment:15 Changed 2 years ago by exarkun

  • Resolution set to fixed
  • Status changed from new to closed

(In [35459]) Merge deprecate-python3-5916-3

Author: exarkun
Reviewer: itamar
Fixes: #5916

Port parts of twisted.python.deprecation to Python 3. The parts ported are
the parts needed by trial to implement its warning-related APIs.

Note: See TracTickets for help on using tickets.