Skip to content

ValueInt causes warnings in Python 3.10 #239

@jontindal

Description

@jontindal

Running under Python 3.10 with pyvsc==0.9.4.16393943433 produces these warnings:
.venv/lib/python3.10/site-packages/vsc/model/field_scalar_model.py:93: DeprecationWarning: __int__ returned non-int (type ValueInt). The ability to return an instance of a strict subclass of int is deprecated, and may be removed in a future version of Python.
.venv/lib/python3.10/site-packages/vsc/model/field_scalar_model.py:93: DeprecationWarning: __int__ returned non-int (type ValueInt). The ability to return an instance of a strict subclass of int is deprecated, and may be removed in a future version of Python.

I think this is due to the ValueScalar type having this function:

    def __int__(self):
        return ValueInt(self.v)

Is this expected and would it be possible to change this behavior to remove the warnings?

Here is a traceback for the warning if helpful:

Traceback (most recent call last):                                                                                                                         
                                                          File "tb.py", line 1057, in run_test                                                     
                                                            test = RandTest()                                                                                                                                      
                                                          File ".venv/lib/python3.10/site-packages/vsc/rand_obj.py", line 82, in __init__             
                                                            self.build_field_model(None)                                                                                                                           
                                                          File ".venv/lib/python3.10/site-packages/vsc/rand_obj.py", line 192, in build_field_model   
                                                            fo._int_field_info.model = fo.build_field_model(f)                                                                                                     
                                                          File ".venv/lib/python3.10/site-packages/vsc/types.py", line 420, in build_field_model      
                                                            self.set_val(self._init_val)                                                                                                                           
                                                          File ".venv/lib/python3.10/site-packages/vsc/types.py", line 476, in set_val                
                                                            self.get_model().set_val(ValueScalar(val))                                                                                                             
                                                          File ".venv/lib/python3.10/site-packages/vsc/model/field_scalar_model.py", line 93, in set_val                                                                                                                                                                                                                 
                                                            self.val.v = int(val)                                                                                                                                  
                                                        DeprecationWarning: __int__ returned non-int (type ValueInt).  The ability to return an instance of a strict subclass of int is deprecated, and may be removed in a future version of Python.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions