Commit 8f5e0004 authored by Jason R. Coombs's avatar Jason R. Coombs

Use mktime for Python 3.2 compatibility

parent abb8efdc
......@@ -3,6 +3,7 @@ import tempfile
import os
import zipfile
import datetime
import time
import pkg_resources
......@@ -11,6 +12,16 @@ try:
except NameError:
unicode = str
def timestamp(dt):
"""
Return a timestamp for a local, naive datetime instance.
"""
try:
return dt.timestamp()
except AttributeError:
# Python 3.2 and earlier
return time.mktime(dt.timetuple())
class EggRemover(unicode):
def __call__(self):
if self in sys.path:
......@@ -77,7 +88,7 @@ class TestZipProvider(object):
f = open(filename, 'w')
f.write('hello, world?')
f.close()
ts = self.ref_time.timestamp()
ts = timestamp(self.ref_time)
os.utime(filename, (ts, ts))
filename = zp.get_resource_filename(manager, 'data.dat')
f = open(filename)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment