Modify ↓
#12977 closed defect (fixed)
"close" method of instance from "Node.get_content()" should be invoked if the method exists
Reported by: | Jun Omae | Owned by: | Jun Omae |
---|---|---|---|
Priority: | normal | Milestone: | 1.0.17 |
Component: | version control | Version: | |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: |
Invoke |
||
API Changes: | |||
Internal Changes: |
Description (last modified by )
Type | Returned value | close | __enter__ , __exit__
|
---|---|---|---|
SubversionNode | FileContentStream instance | available | n/a |
GitNode | cStringIO.StringIO instance | available | n/a *1 |
MercurialNode | self | n/a | n/a |
*1 io.BytesIO
has __enter__
-
trac/versioncontrol/web_ui/changeset.py
diff --git a/trac/versioncontrol/web_ui/changeset.py b/trac/versioncontrol/web_ui/changeset.py index d9831a4d5..b82c1df3a 100644
a b class ChangesetModule(Component): 549 549 return None 550 550 if mview.is_binary(new_node.content_type, new_node.path): 551 551 return None 552 old_content = old_node.get_content().read()552 old_content = _read_content(old_node) 553 553 if mview.is_binary(content=old_content): 554 554 return None 555 new_content = new_node.get_content().read()555 new_content = _read_content(new_node) 556 556 if mview.is_binary(content=new_content): 557 557 return None 558 558 … … class ChangesetModule(Component): 719 719 continue 720 720 if mimeview.is_binary(old_node.content_type, old_node.path): 721 721 continue 722 old_content = old_node.get_content().read()722 old_content = _read_content(old_node) 723 723 if mimeview.is_binary(content=old_content): 724 724 continue 725 725 old_node_info = (old_node.path, old_node.rev) … … class ChangesetModule(Component): 730 730 continue 731 731 if mimeview.is_binary(new_node.content_type, new_node.path): 732 732 continue 733 new_content = new_node.get_content().read()733 new_content = _read_content(new_node) 734 734 if mimeview.is_binary(content=new_content): 735 735 continue 736 736 new_node_info = (new_node.path, new_node.rev) … … class AnyDiffModule(Component): 1226 1226 1227 1227 add_script(req, 'common/js/suggest.js') 1228 1228 return 'diff_form.html', data, None 1229 1230 1231 def _read_content(node): 1232 content = node.get_content() 1233 try: 1234 return content.read() 1235 finally: 1236 if hasattr(content, 'close'): 1237 content.close() -
tracopt/versioncontrol/svn/svn_fs.py
diff --git a/tracopt/versioncontrol/svn/svn_fs.py b/tracopt/versioncontrol/svn/svn_fs.py index 6b0ae405a..4f50f319a 100644
a b class FileContentStream(object): 1198 1198 node._scoped_path_utf8, 1199 1199 self.pool())) 1200 1200 1201 def __enter__(self): 1202 return self 1203 1204 def __exit__(self, et, ev, tb): 1205 self.close() 1206 1201 1207 def __del__(self): 1202 1208 self.close() 1203 1209
Attachments (0)
Change History (6)
comment:1 by , 7 years ago
Description: | modified (diff) |
---|
comment:3 by , 7 years ago
Release Notes: | modified (diff) |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Thanks! Committed in [16591] and merged in [16592-16593].
comment:4 by , 7 years ago
Owner: | set to |
---|
comment:6 by , 7 years ago
Hmm, I often wrongly merge such lines from 1.0-stable.
I added the following lines to my Makefile.cfg
to check the cases before unit-test:
test-py26 : grep -q '^min_python = (2, [0-5])' setup.py || ( \ ! grep -r --include='*.py' '\<import *with_statement\>' . && \ ! grep -r --include='*.py' '\<except *.*, *[A-Za-z0-9_]\+:' . \ ) unit-test : test-py26
Note:
See TracTickets
for help on using tickets.
Revised patch: [3f87f5802/jomae.git] (jomae.git@t12977)