You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2013/09/17 21:12:07 UTC

[09/20] git commit: [#6652] don't use mktime() which assumes time tuple is local time

[#6652] don't use mktime() which assumes time tuple is local time


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/68c74e40
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/68c74e40
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/68c74e40

Branch: refs/heads/db/5822
Commit: 68c74e40c577aa03eaef7fdce586c90c72e10c1f
Parents: 1ce95a3
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Thu Sep 12 14:43:09 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Mon Sep 16 21:42:44 2013 +0000

----------------------------------------------------------------------
 AlluraTest/alluratest/test_syntax.py                | 4 +++-
 ForgeBlog/forgeblog/command/rssfeeds.py             | 4 ++--
 ForgeDiscussion/forgediscussion/controllers/root.py | 5 +++--
 3 files changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/68c74e40/AlluraTest/alluratest/test_syntax.py
----------------------------------------------------------------------
diff --git a/AlluraTest/alluratest/test_syntax.py b/AlluraTest/alluratest/test_syntax.py
index b394798..b72052c 100644
--- a/AlluraTest/alluratest/test_syntax.py
+++ b/AlluraTest/alluratest/test_syntax.py
@@ -69,11 +69,13 @@ def test_pyflakes():
     if error:
         raise Exception('pyflakes failure, see stdout')
 
-def test_no_now():
+def test_no_local_tz_functions():
     if run(find_py + " | xargs grep '\.now(' ") not in [1,123]:
         raise Exception("These should use .utcnow()")
     if run(find_py + " | xargs grep '\.fromtimestamp(' ") not in [1,123]:
         raise Exception("These should use .utcfromtimestamp()")
+    if run(find_py + " | xargs grep 'mktime(' ") not in [1,123]:
+        raise Exception("These should use calendar.timegm()")
 
 def test_no_prints():
     skips = [

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/68c74e40/ForgeBlog/forgeblog/command/rssfeeds.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/command/rssfeeds.py b/ForgeBlog/forgeblog/command/rssfeeds.py
index 0e70ea9..eeac4b2 100644
--- a/ForgeBlog/forgeblog/command/rssfeeds.py
+++ b/ForgeBlog/forgeblog/command/rssfeeds.py
@@ -15,7 +15,7 @@
 #       specific language governing permissions and limitations
 #       under the License.
 
-from time import mktime
+import calendar
 from datetime import datetime
 import re
 
@@ -128,7 +128,7 @@ class RssFeedsCommand(base.BlogCommand):
                                             getattr(e, 'title'))))
 
         content += u' [link](%s)' % e.link
-        updated = datetime.utcfromtimestamp(mktime(e.updated_parsed))
+        updated = datetime.utcfromtimestamp(calendar.timegm(e.updated_parsed))
 
         base_slug = BM.BlogPost.make_base_slug(title, updated)
         b_count = BM.BlogPost.query.find(dict(slug=base_slug, app_config_id=appid)).count()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/68c74e40/ForgeDiscussion/forgediscussion/controllers/root.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/controllers/root.py b/ForgeDiscussion/forgediscussion/controllers/root.py
index c6f9019..aa1130e 100644
--- a/ForgeDiscussion/forgediscussion/controllers/root.py
+++ b/ForgeDiscussion/forgediscussion/controllers/root.py
@@ -19,9 +19,10 @@ import json
 import logging
 from urllib import unquote
 from datetime import date, datetime, timedelta, time
-from time import mktime
+import calendar
 from collections import OrderedDict
 
+
 from tg import expose, validate, redirect, flash, response
 from tg.decorators import with_trailing_slash, without_trailing_slash
 from pylons import tmpl_context as c, app_globals as g
@@ -271,7 +272,7 @@ class RootController(BaseController, DispatchIndex, FeedController):
         def reformat_data(mongo_data):
             def item(day, val):
                 return [
-                    mktime(day.timetuple()) * 1000,
+                    calendar.timegm(day.timetuple()) * 1000,
                     val
                 ]