[INSTRM-1690] Fix opscore.protocol.types formatting for python 3.8+ Created: 03/Sep/22  Updated: 06/Sep/22  Resolved: 06/Sep/22

Status: Done
Project: Instrument control development
Component/s: tron_actorcore
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Normal
Reporter: cloomis Assignee: cloomis
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

python 3.8 changes the way class _str methods are resolved. For class objects, obj.str now resolves to object.str; for instances obj.str resolves to obj.class.str_, which is what used to happen in both cases.

Because of the way metaclasses are used in opscore types, the basic opscore.protocol.types (Int, Float, etc) use the class _str under normal circumstances, which now resolves to object.str instead of, say float.str_. And which returns, say, "Float(1.23)" instead of the desired "1.23".

This is a problem when formatting MHS typed objects.

I think the answer is simply to instantiate the base object in _str_(), except for String (i.e. baseType=str) objects. Testing now.



 Comments   
Comment by cloomis [ 06/Sep/22 ]

Merged at e5e0516, tagged 2.4.4

Generated at Sat Feb 10 16:38:23 JST 2024 using Jira 8.3.4#803005-sha1:1f96e09b3c60279a408a2ae47be3c745f571388b.