Skip to content

Commit

Permalink
fix: arrow 'timestamp' property removed in >=v1.0.0
Browse files Browse the repository at this point in the history
The missing property in newer arrow versions, caused that variables only contained references like '<bound method Arrow.timestamp of <Arrow [2023-01-15T02:16:14.627656+00:00]>>' instead the actual timestamp values.
Tests in 'tests/test_pagure_flask_dump_load_ticket.py' failed with 'ValueError: could not convert string to float'.

References
https://arrow.readthedocs.io/en/latest/releases.html
Quote: 'Calls to the timestamp property now emit a DeprecationWarning.'

arrow-py/arrow#832
Quote: 'The .timestamp property has been removed to improve compatibility with datetime. Use .int_timestamp for the same results.'

libgit2/pygit2#1122
  • Loading branch information
wombelix committed Jan 22, 2023
1 parent e830f17 commit 39b99cc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pagure/lib/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ def create_default_status(session, acls=None):


def arrow_ts(value):
return "%s" % arrow.get(value).timestamp
if hasattr(arrow, 'timestamp'):
return "%s" % arrow.get(value).timestamp # arrow < v1.0.0
else:
return "%s" % arrow.get(value).int_timestamp # arrow >= v1.0.0


class AccessLevels(BASE):
Expand Down

0 comments on commit 39b99cc

Please sign in to comment.