Merge remote-tracking branch 'mmn/mktime_takes_localtime_not_gmtime' into develop

* FIX struct_time inputs to time.mktime() to use localtime() not gmtime().
 * CLOSES #9: "mktime takes local time, not UTC"
   https://github.com/isislovecruft/python-gnupg/pull/9
testing/mmn/xrange_replaces_range_in_python3
Isis Lovecruft 2013-07-26 14:32:43 +00:00
commit 8bad2f3c05
No known key found for this signature in database
GPG Key ID: A3ADB67A2CDB8B35
2 changed files with 6 additions and 6 deletions

View File

@ -23,7 +23,7 @@ Extra utilities for python-gnupg.
from __future__ import absolute_import
from datetime import datetime
from socket import gethostname
from time import gmtime
from time import localtime
from time import mktime
import codecs
@ -330,7 +330,7 @@ def _make_passphrase(length=None, save=False, file=None):
if save:
ruid, euid, suid = os.getresuid()
gid = os.getgid()
now = mktime(gmtime())
now = mktime(localtime())
if not file:
filename = str('passphrase-%s-%s' % uid, now)
@ -387,8 +387,8 @@ def _threaded_copy_data(instream, outstream):
return copy_thread
def _utc_epoch():
"""Get the seconds since epoch for UTC."""
return int(mktime(gmtime()))
"""Get the seconds since epoch."""
return int(mktime(localtime()))
def _which(executable, flags=os.X_OK):
"""Borrowed from Twisted's :mod:twisted.python.proutils .

View File

@ -28,7 +28,7 @@ from argparse import ArgumentParser
from codecs import open as open
from functools import wraps
from glob import glob
from time import gmtime
from time import localtime
from time import mktime
import encodings
@ -645,7 +645,7 @@ class GPGTestCase(unittest.TestCase):
message += '[hackers in popular culture] to push for more power'
sig = self.gpg.sign(message, default_key=key.fingerprint,
passphrase='bruceschneier')
now = mktime(gmtime())
now = mktime(localtime())
self.assertTrue(sig, "Good passphrase should succeed")
verified = self.gpg.verify(sig.data)
self.assertIsNotNone(verified.fingerprint)