diff options
Diffstat (limited to 'Lib/lib2to3')
-rw-r--r-- | Lib/lib2to3/__main__.py | 4 | ||||
-rw-r--r-- | Lib/lib2to3/fixer_base.py | 4 | ||||
-rw-r--r-- | Lib/lib2to3/pytree.py | 20 | ||||
-rw-r--r-- | Lib/lib2to3/refactor.py | 4 | ||||
-rw-r--r-- | Lib/lib2to3/tests/test_pytree.py | 17 |
5 files changed, 7 insertions, 42 deletions
diff --git a/Lib/lib2to3/__main__.py b/Lib/lib2to3/__main__.py new file mode 100644 index 0000000..80688ba --- /dev/null +++ b/Lib/lib2to3/__main__.py @@ -0,0 +1,4 @@ +import sys +from .main import main + +sys.exit(main("lib2to3.fixes")) diff --git a/Lib/lib2to3/fixer_base.py b/Lib/lib2to3/fixer_base.py index afc0467..b176056 100644 --- a/Lib/lib2to3/fixer_base.py +++ b/Lib/lib2to3/fixer_base.py @@ -27,7 +27,6 @@ class BaseFix(object): pattern_tree = None # Tree representation of the pattern options = None # Options object passed to initializer filename = None # The filename (set by set_filename) - logger = None # A logger (set by set_filename) numbers = itertools.count(1) # For new_name() used_names = set() # A set of all used NAMEs order = "post" # Does the fixer prefer pre- or post-order traversal @@ -70,12 +69,11 @@ class BaseFix(object): with_tree=True) def set_filename(self, filename): - """Set the filename, and a logger derived from it. + """Set the filename. The main refactoring tool should call this. """ self.filename = filename - self.logger = logging.getLogger(filename) def match(self, node): """Returns match for a given parse tree node. diff --git a/Lib/lib2to3/pytree.py b/Lib/lib2to3/pytree.py index fa4942f3..17cbf0a 100644 --- a/Lib/lib2to3/pytree.py +++ b/Lib/lib2to3/pytree.py @@ -109,26 +109,6 @@ class Base(object): """ raise NotImplementedError - def set_prefix(self, prefix): - """ - Set the prefix for the node (see Leaf class). - - DEPRECATED; use the prefix property directly. - """ - warnings.warn("set_prefix() is deprecated; use the prefix property", - DeprecationWarning, stacklevel=2) - self.prefix = prefix - - def get_prefix(self): - """ - Return the prefix for the node (see Leaf class). - - DEPRECATED; use the prefix property directly. - """ - warnings.warn("get_prefix() is deprecated; use the prefix property", - DeprecationWarning, stacklevel=2) - return self.prefix - def replace(self, new): """Replace this node with a new one in the parent.""" assert self.parent is not None, str(self) diff --git a/Lib/lib2to3/refactor.py b/Lib/lib2to3/refactor.py index 38fb8ed..201e193 100644 --- a/Lib/lib2to3/refactor.py +++ b/Lib/lib2to3/refactor.py @@ -566,7 +566,7 @@ class RefactoringTool(object): block_lineno = None indent = None lineno = 0 - for line in input.splitlines(True): + for line in input.splitlines(keepends=True): lineno += 1 if line.lstrip().startswith(self.PS1): if block is not None: @@ -610,7 +610,7 @@ class RefactoringTool(object): filename, lineno, err.__class__.__name__, err) return block if self.refactor_tree(tree, filename): - new = str(tree).splitlines(True) + new = str(tree).splitlines(keepends=True) # Undo the adjustment of the line numbers in wrap_toks() below. clipped, new = new[:lineno-1], new[lineno-1:] assert clipped == ["\n"] * (lineno-1), clipped diff --git a/Lib/lib2to3/tests/test_pytree.py b/Lib/lib2to3/tests/test_pytree.py index ac7d900..a2ab1f3 100644 --- a/Lib/lib2to3/tests/test_pytree.py +++ b/Lib/lib2to3/tests/test_pytree.py @@ -31,23 +31,6 @@ class TestNodes(support.TestCase): """Unit tests for nodes (Base, Leaf, Node).""" - if sys.version_info >= (2,6): - # warnings.catch_warnings is new in 2.6. - def test_deprecated_prefix_methods(self): - l = pytree.Leaf(100, "foo") - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always", DeprecationWarning) - self.assertEqual(l.get_prefix(), "") - l.set_prefix("hi") - self.assertEqual(l.prefix, "hi") - self.assertEqual(len(w), 2) - for warning in w: - self.assertTrue(warning.category is DeprecationWarning) - self.assertEqual(str(w[0].message), "get_prefix() is deprecated; " \ - "use the prefix property") - self.assertEqual(str(w[1].message), "set_prefix() is deprecated; " \ - "use the prefix property") - def test_instantiate_base(self): if __debug__: # Test that instantiating Base() raises an AssertionError |