Repository: unihd-cag/skillbridge (language: python)

Issue:
get_inst_CDF results  in ValueError when printed
Simple Example:

```
ws = Workspace.open()
cv = ws.ge.get_edit_cell_view()
inst = cv.instances[0]
cdf = ws.cdf.get_inst_CDF(inst)

print(cdf)
>>> ValueError: invalid literal for int() with base 16: '0x0x2b7dfac0'
```


Discussion / hints:

Fix patch:
diff --git a/skillbridge/client/objects.py b/skillbridge/client/objects.py
index a28b4fe..f41956f 100644
--- a/skillbridge/client/objects.py
+++ b/skillbridge/client/objects.py
@@ -40,11 +40,13 @@ def __init__(self, channel: Channel, variable: str, translator: Translator) -> N
 
     @property
     def skill_id(self) -> int:
-        addr = self._variable[5:].rsplit('_', maxsplit=1)[1]
+        address = self._variable[5:].rsplit('_', maxsplit=1)[1]
         try:
-            return int(addr, 0)
+            return int(address, 0)
         except ValueError:
-            return int(addr, 16)
+            if address.startswith('0x0x'):  # some skill objects have two '0x' in their name
+                address = address[2:]
+            return int(address, 16)
 
     @property
     def skill_parent_type(self) -> str:


Test patch:
diff --git a/tests/test_misc.py b/tests/test_misc.py
index 843de83..59a01e4 100644
--- a/tests/test_misc.py
+++ b/tests/test_misc.py
@@ -139,3 +139,8 @@ def test_lazy_list():
     assert 'TEST~>shapes' in repr(l.shapes)
 
     assert RemoteObject(channel, SkillCode('TESTTEST_123'), translator).lazy.shapes._variable == 'TESTTEST_123~>shapes'
+
+
+def test_double_hex_prefix_does_not_crash():
+    assert RemoteObject(..., '__py_stuff_0x0xcafe', ...).skill_id == 0xcafe
+    assert RemoteObject(..., '__py_stuff_0xcafe', ...).skill_id == 0xcafe