Skip to content
Snippets Groups Projects
Commit 5217b9c5 authored by alekum's avatar alekum
Browse files

Fix implicit recursion via __repr__ call for unsync changes

parent 497a55f5
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -88,4 +88,4 @@ tramp
/auto/
 
# PyCharm files
.idea/*.*
\ No newline at end of file
.idea/
\ No newline at end of file
Loading
Loading
@@ -118,7 +118,14 @@ class Path(object):
parent = parent.node_list
 
if isinstance(parent, NodeList):
pos = parent.index(node.node_list if isinstance(node, ProxyList) else node)
if isinstance(node, ProxyList):
item = node.node_list
else:
item = node
# TODO(alekum) Error occurs here, because the tree is not synchronized internally.
# And the node which is inserted is not contained in the node_list of the target tree.
# But it's contained in data section. =/
pos = parent.index(item)
return pos
 
if isinstance(node, NodeList):
Loading
Loading
@@ -973,7 +980,7 @@ class Node(GenericNodesUtils):
 
return "<%s path=%s, \"%s\" %s, on %s %s>" % (
self.__class__.__name__,
self.path().to_baron_path(),
self.path().to_baron_path(), #TODO(alekum) this call is being recursive
truncate(self.dumps().replace("\n", "\\n"), 20),
id(self),
self.parent.__class__.__name__,
Loading
Loading
@@ -1640,9 +1647,9 @@ class LineProxyList(ProxyList):
{"type": "endl", "formatting": [], "value": "\n", "indent": " "})
 
def _synchronise(self):
log("Before synchronise, self.data = '%s' + '%s'", self.first_blank_lines, self.data)
log("Before synchronise, self.data = '%s' + '%s'", self.first_blank_lines, self.node_list)
super(LineProxyList, self)._synchronise()
log("After synchronise, self.data = '%s' + '%s'", self.first_blank_lines, self.data)
log("After synchronise, self.data = '%s' + '%s'", self.first_blank_lines, self.node_list)
 
def _build_inner_list(self, node_list):
result = []
Loading
Loading
Loading
Loading
@@ -8,8 +8,8 @@ import pytest
import redbaron
from redbaron import RedBaron
 
redbaron.DEBUG = True
# (alekum): switch off debug mode, to reproduce a bug with __repr__ implicit recursion
redbaron.DEBUG = False
 
def assert_with_indent(left, right):
# Replace is not strictly necessary but shows indents
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment