Python 3.10 for x86 field test - asctim

Post Reply
User avatar

Topic author
imiller
Master
Posts: 155
Joined: Fri Jun 28, 2019 8:45 am
Reputation: 0
Location: South Tyneside, UK
Status: Offline
Contact:

Python 3.10 for x86 field test - asctim

Post by imiller » Wed May 08, 2024 6:24 am

Here is a little python function which is intended to return how many days before now is the specified VMS time.

Code: Select all

def daysb4(time):

    sts, now = SYS.gettim()
    if (sts & 1) == 1:  # if sucessfully got current time
        sts, time_since = SYS.asctim(time - now, 0)     # convert time to string delta time before now

    if (sts & 1) == 1:
        days_since = 0 + time_since.split("+")	# extract the days
        return days_since
    else:
        return 99999    # indicate error by returning number bigger than any valid delta time
    #endif
#end daysb4
However, what I get is an error that I'm passing a negative number. This should be allowed as VMS binary delta times are negative.

Code: Select all

OverflowError: can't convert negative int to unsigned

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/DATA/IMILLER/PY/fh2.py", line 295, in <module>
    print("rev days b4",daysb4(fi.revdate))
  File "/DATA/IMILLER/PY/fh2.py", line 237, in daysb4
    sts, time_since = SYS.asctim(time - now, 0) # convert time to string delta time before now
SystemError: <built-in function asctim> returned a result with an exception set
Ian Miller
[ personal opinion only. usual disclaimers apply. Do not taunt happy fun ball ].

User avatar

arne_v
Master
Posts: 381
Joined: Fri Apr 17, 2020 7:31 pm
Reputation: 0
Location: Rhode Island, USA
Status: Offline
Contact:

Re: Python 3.10 for x86 field test - asctim

Post by arne_v » Wed May 08, 2024 3:29 pm

It should work per documentation:

https://wiki.vmssoftware.com/VMS-Specif ... 29-.3Elist

But it does not.

Even though it can be worked around:

Code: Select all

$ type t.py
from vms import sys

dt = -10000000
print(sys.asctim(dt, 0))
$ python t.py
OverflowError: can't convert negative int to unsigned

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/DISK2/ARNE/t.py", line 4, in <module>
    print(sys.asctim(dt, 0))
SystemError: <built-in function asctim> returned a result with an exception set
$ type t2.py
from vms import sys

dt = -10000000
dt = dt & 0x0FFFFFFFFFFFFFFFF
print(sys.asctim(dt, 0))
$ python t2.py
(1, '   0 00:00:01.00')
Arne
arne@vajhoej.dk
VMS user since 1986


craigberry
Active Contributor
Posts: 25
Joined: Fri Nov 17, 2023 11:27 am
Reputation: 1
Status: Offline

Re: Python 3.10 for x86 field test - asctim

Post by craigberry » Wed May 08, 2024 6:37 pm

Someone probably just used an integer of the wrong sign somewhere. If the source were open, it likely would have been found and fixed today.

User avatar

arne_v
Master
Posts: 381
Joined: Fri Apr 17, 2020 7:31 pm
Reputation: 0
Location: Rhode Island, USA
Status: Offline
Contact:

Re: Python 3.10 for x86 field test - asctim

Post by arne_v » Thu May 09, 2024 7:15 am

The GitHub repo is there:

https://github.com/vmssoftware/cpython

But it is obviously not uptodate. Last change is 3 years ago.
Arne
arne@vajhoej.dk
VMS user since 1986


sergey_vorfolomeev
VSI Expert
Master
Posts: 103
Joined: Thu Aug 22, 2019 12:17 am
Reputation: 0
Status: Offline

Re: Python 3.10 for x86 field test - asctim

Post by sergey_vorfolomeev » Fri May 10, 2024 4:35 am

The current branch is 'openvms-3.10.0'.

Modules\vms\sys\_sys.c, line 126

Code: Select all

unsigned long long vms_time = PyLong_AsUnsignedLongLong(args[0]);
That must be just 'long long'.

Code: Select all

long long vms_time = PyLong_AsLongLong(args[0]);
I will fix and test that.

User avatar

arne_v
Master
Posts: 381
Joined: Fri Apr 17, 2020 7:31 pm
Reputation: 0
Location: Rhode Island, USA
Status: Offline
Contact:

Re: Python 3.10 for x86 field test - asctim

Post by arne_v » Fri May 10, 2024 6:30 am

sergey_vorfolomeev wrote:
Fri May 10, 2024 4:35 am
The current branch is 'openvms-3.10.0'.
Ah.

https://github.com/vmssoftware/cpython/ ... vms-3.10.0
sergey_vorfolomeev wrote:
Fri May 10, 2024 4:35 am
Modules\vms\sys\_sys.c, line 126

Code: Select all

unsigned long long vms_time = PyLong_AsUnsignedLongLong(args[0]);
That must be just 'long long'.

Code: Select all

long long vms_time = PyLong_AsLongLong(args[0]);
I will fix and test that.
https://github.com/vmssoftware/cpython/ ... sys/_sys.c

https://github.com/vmssoftware/cpython/ ... 9259d1d0dc
Arne
arne@vajhoej.dk
VMS user since 1986

User avatar

Topic author
imiller
Master
Posts: 155
Joined: Fri Jun 28, 2019 8:45 am
Reputation: 0
Location: South Tyneside, UK
Status: Offline
Contact:

Re: Python 3.10 for x86 field test - asctim

Post by imiller » Mon May 13, 2024 11:45 am

That's good - I look forward to that fix in the next release.
Ian Miller
[ personal opinion only. usual disclaimers apply. Do not taunt happy fun ball ].

Post Reply