Show More
@@ -161,7 +161,22 b' def makefileobj(repo, pat, node=None, to' | |||||
161 |
|
161 | |||
162 | if not pat or pat == '-': |
|
162 | if not pat or pat == '-': | |
163 | fp = writable and repo.ui.fout or repo.ui.fin |
|
163 | fp = writable and repo.ui.fout or repo.ui.fin | |
164 | return os.fdopen(os.dup(fp.fileno()), mode) |
|
164 | if hasattr(fp, 'fileno'): | |
|
165 | return os.fdopen(os.dup(fp.fileno()), mode) | |||
|
166 | else: | |||
|
167 | # if this fp can't be duped properly, return | |||
|
168 | # a dummy object that can be closed | |||
|
169 | class wrappedfileobj(object): | |||
|
170 | noop = lambda x: None | |||
|
171 | def __init__(self, f): | |||
|
172 | self.f = f | |||
|
173 | def __getattr__(self, attr): | |||
|
174 | if attr == 'close': | |||
|
175 | return self.noop | |||
|
176 | else: | |||
|
177 | return getattr(self.f, attr) | |||
|
178 | ||||
|
179 | return wrappedfileobj(fp) | |||
165 | if hasattr(pat, 'write') and writable: |
|
180 | if hasattr(pat, 'write') and writable: | |
166 | return pat |
|
181 | return pat | |
167 | if hasattr(pat, 'read') and 'r' in mode: |
|
182 | if hasattr(pat, 'read') and 'r' in mode: |
General Comments 0
You need to be logged in to leave comments.
Login now