Mercurial > public > mercurial-scm > hg
comparison mercurial/ui.py @ 25660:328739ea70c3
global: mass rewrite to use modern exception syntax
Python 2.6 introduced the "except type as instance" syntax, replacing
the "except type, instance" syntax that came before. Python 3 dropped
support for the latter syntax. Since we no longer support Python 2.4 or
2.5, we have no need to continue supporting the "except type, instance".
This patch mass rewrites the exception syntax to be Python 2.6+ and
Python 3 compatible.
This patch was produced by running `2to3 -f except -w -n .`.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 23 Jun 2015 22:20:08 -0700 |
parents | 52e5f68d8363 |
children | 2cc4e8385661 |
comparison
equal
deleted
inserted
replaced
25659:d60678a567a9 | 25660:328739ea70c3 |
---|---|
151 trusted = sections or trust or self._trusted(fp, filename) | 151 trusted = sections or trust or self._trusted(fp, filename) |
152 | 152 |
153 try: | 153 try: |
154 cfg.read(filename, fp, sections=sections, remap=remap) | 154 cfg.read(filename, fp, sections=sections, remap=remap) |
155 fp.close() | 155 fp.close() |
156 except error.ConfigError, inst: | 156 except error.ConfigError as inst: |
157 if trusted: | 157 if trusted: |
158 raise | 158 raise |
159 self.warn(_("ignored: %s\n") % str(inst)) | 159 self.warn(_("ignored: %s\n") % str(inst)) |
160 | 160 |
161 if self.plain(): | 161 if self.plain(): |
603 self.ferr.write(str(a)) | 603 self.ferr.write(str(a)) |
604 # stderr may be buffered under win32 when redirected to files, | 604 # stderr may be buffered under win32 when redirected to files, |
605 # including stdout. | 605 # including stdout. |
606 if not getattr(self.ferr, 'closed', False): | 606 if not getattr(self.ferr, 'closed', False): |
607 self.ferr.flush() | 607 self.ferr.flush() |
608 except IOError, inst: | 608 except IOError as inst: |
609 if inst.errno not in (errno.EPIPE, errno.EIO, errno.EBADF): | 609 if inst.errno not in (errno.EPIPE, errno.EIO, errno.EBADF): |
610 raise | 610 raise |
611 | 611 |
612 def flush(self): | 612 def flush(self): |
613 try: self.fout.flush() | 613 try: self.fout.flush() |