archival: avoid touching deprecated gzip name attribute
The existing workaround didn't work when no filename was specified.
If running in a context with warnings enabled and subsecond mtime it gave a
warning:
DeprecationWarning: use the name attribute
--- a/mercurial/archival.py Thu Jan 03 21:07:04 2013 +0100
+++ b/mercurial/archival.py Thu Jan 03 21:07:04 2013 +0100
@@ -74,8 +74,11 @@
def _write_gzip_header(self):
self.fileobj.write('\037\213') # magic header
self.fileobj.write('\010') # compression method
- # Python 2.6 deprecates self.filename
- fname = getattr(self, 'name', None) or self.filename
+ # Python 2.6 introduced self.name and deprecated self.filename
+ try:
+ fname = self.name
+ except AttributeError:
+ fname = self.filename
if fname and fname.endswith('.gz'):
fname = fname[:-3]
flags = 0