Shortly after moving the jail dvl-ingress01 from Python 3.11 to Python 3.12, I started seeing these messages:
/usr/local/libexec/freshports/git-to-freshports-xml.py:179: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
The code in question ( link to source) is
commit_datetime = datetime.datetime.utcfromtimestamp(commit.commit_time)
This should be easy enough to replace, knowing python.
First, reproduce the problem
With any change to fix a problem, I must first be able to reproduce the problem. That is only way to demonstrate the problem is fixed.
Here’s my idea. This command took far too long to figure out. I’m going to test using my recent commit.
$ pwd /usr/local/libexec/freshports $ id uid=10002(ingress) gid=10002(ingress) groups=10002(ingress),10001(freshports) $ python /usr/home/dvl/src/git_proc_commit/git-to-freshports/git-to-freshports-xml.py \ --repo ports \ --path /var/db/ingress/repos/ports \ --branch main \ --single-commit b27a2fd7ce0fcd91dad3dfe4fd19ded53db270fc \ --spooling /var/db/ingress/message-queues/spooling \ --output /tmp /usr/home/dvl/src/git_proc_commit/git-to-freshports/git-to-freshports-xml.py:179: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC). commit_datetime = datetime.datetime.utcfromtimestamp(commit.commit_time)
The output from that command is:
[13:25 dvl-ingress01 dvl ~/src/git_proc_commit/git-to-freshports] % ls -l /tmp
total 6
-rw-rw-r-- 1 ingress wheel 954 2026.01.21 13:26 2026.01.21.12.12.57.000000.b27a2fd7ce0fcd91dad3dfe4fd19ded53db270fc.xml
drwx------ 2 dvl wheel 3 2026.01.21 12:22 ssh-FeNnrEIMXW/
drwx------ 2 dvl wheel 3 2026.01.21 12:38 ssh-SGd9RXxYja/
drwx------ 2 dvl wheel 3 2026.01.21 12:37 ssh-zBMHv11pFh/
[13:26 dvl-ingress01 dvl ~/src/git_proc_commit/git-to-freshports] % cat /tmp/2026.01.21.12.12.57.000000.b27a2fd7ce0fcd91dad3dfe4fd19ded53db270fc.xml
<?xml version='1.0' encoding='UTF-8'?>
<UPDATES Version="1.5.0.0" Source="git">
<UPDATE>
<DATE Year="2026" Month="1" Day="21"/>
<TIME Timezone="UTC" Hour="12" Minute="12" Second="57"/>
<OS Repo="ports" Id="FreeBSD" Branch="main"/>
<LOG>Mk/Scripts: add /usr/libexec/flua to shebangs
Allow scripts to use /usr/libexec/flua from base
Without this, such scripts are told:
Error: '/usr/libexec/flua' is an invalid shebang you need
USES=shebangfix for 'foo'
PR: 292553</LOG>
<PEOPLE>
<COMMITTER CommitterName="Dan Langille" CommitterEmail="dvl@FreeBSD.org"/>
<AUTHOR AuthorName="Dan Langille" AuthorEmail="dvl@FreeBSD.org"/>
</PEOPLE>
<COMMIT Hash="b27a2fd7ce0fcd91dad3dfe4fd19ded53db270fc" HashShort="b27a2fd7" Subject="Mk/Scripts: add /usr/libexec/flua to shebangs" EncodingLoses="false" Repository="ports"/>
<FILES>
<FILE Action="Modify" Path="Mk/Scripts/qa.sh"/>
</FILES>
</UPDATE>
</UPDATES>
[13:26 dvl-ingress01 dvl ~/src/git_proc_commit/git-to-freshports] %
I checked: that output matches the original XML as confirmed by this output (or rather, lack of output):
[13:25 dvl-ingress01 dvl ~/src/git_proc_commit/git-to-freshports] % diff -ruN /tmp/2026.01.21.12.12.57.000000.b27a2fd7ce0fcd91dad3dfe4fd19ded53db270fc.xml ~freshports/message-queues/recent/2026.01.21.12.12.57.000000.b27a2fd7ce0fcd91dad3dfe4fd19ded53db270fc.xml [13:25 dvl-ingress01 dvl ~/src/git_proc_commit/git-to-freshports] % ls -l /tmp total 6 -rw-rw-r-- 1 ingress wheel 954 2026.01.21 13:26 2026.01.21.12.12.57.000000.b27a2fd7ce0fcd91dad3dfe4fd19ded53db270fc.xml drwx------ 2 dvl wheel 3 2026.01.21 12:22 ssh-FeNnrEIMXW/ drwx------ 2 dvl wheel 3 2026.01.21 12:38 ssh-SGd9RXxYja/ drwx------ 2 dvl wheel 3 2026.01.21 12:37 ssh-zBMHv11pFh/
Now that I can reproduce the error, I’ll work on fixing it.
The proposed fix
Based on my searches, I found this recommended change:
[15:09 dvl-ingress01 dvl ~/src/git_proc_commit/git-to-freshports] % git diff
diff --git a/git-to-freshports/git-to-freshports-xml.py b/git-to-freshports/git-to-freshports-xml.py
index 15553a8..0a6bd14 100755
--- a/git-to-freshports/git-to-freshports-xml.py
+++ b/git-to-freshports/git-to-freshports-xml.py
@@ -176,7 +176,7 @@ def main():
update = ET.SubElement(root, 'UPDATE')
log.debug("Getting commit datetime")
- commit_datetime = datetime.datetime.utcfromtimestamp(commit.commit_time)
+ commit_datetime = datetime.datetime.fromtimestamp(commit.commit_time, tz=datetime.UTC)
log.debug(f"Commit datetime: {commit_datetime}")
log.debug("Writing commit date")
[15:09 dvl-ingress01 dvl ~/src/git_proc_commit/git-to-freshports] %
Testing it:
$ python /usr/home/dvl/src/git_proc_commit/git-to-freshports/git-to-freshports-xml.py \ --repo ports \ --path /var/db/ingress/repos/ports \ --branch main \ --single-commit b27a2fd7ce0fcd91dad3dfe4fd19ded53db270fc \ --spooling /var/db/ingress/message-queues/spooling \ --output /tmp $ diff -ruN /tmp/2026.01.21.12.12.57.000000.b27a2fd7ce0fcd91dad3dfe4fd19ded53db270fc.xml ~freshports/message-queues/recent/2026.01.21.12.12.57.000000.b27a2fd7ce0fcd91dad3dfe4fd19ded53db270fc.xml $ date Wed Jan 21 15:10:47 UTC 2026 $ ls -l /tmp/2026.01.21.12.12.57.000000.b27a2fd7ce0fcd91dad3dfe4fd19ded53db270fc.xml -rw-rw-r-- 1 ingress wheel 954 Jan 21 15:09 /tmp/2026.01.21.12.12.57.000000.b27a2fd7ce0fcd91dad3dfe4fd19ded53db270fc.xml $
No more error message. Good. And the diff proves the output is identical to the original.
Let’s look at the DATE and TIME values from each output file:
$ grep -hE 'DATE|TIME' /tmp/2026.01.21.12.12.57.000000.b27a2fd7ce0fcd91dad3dfe4fd19ded53db270fc.xml
<UPDATES Version="1.5.0.0" Source="git">
<UPDATE>
<DATE Year="2026" Month="1" Day="21"/>
<TIME Timezone="UTC" Hour="12" Minute="12" Second="57"/>
</UPDATE>
</UPDATES>
$ grep -hE 'DATE|TIME' ~freshports/message-queues/recent/2026.01.21.12.12.57.000000.b27a2fd7ce0fcd91dad3dfe4fd19ded53db270fc.xml
<UPDATES Version="1.5.0.0" Source="git">
<UPDATE>
<DATE Year="2026" Month="1" Day="21"/>
<TIME Timezone="UTC" Hour="12" Minute="12" Second="57"/>
</UPDATE>
</UPDATES>
$
Yes, they match up. And the values match those found in the original commit.
What’s next?
I’ll commit this change, build new packages, and deploy them to both this host (dvl-ingress01) and to dev (dev-ingress01).
Fixed in 0.2.3











