Content-Length: 217291 | pFad | http://github.com/py2many/py2many/commit/affbf1b6942a72af62dc6a7be353bb118546d189

7B fix tests/test_unsupported.py dict_del · py2many/py2many@affbf1b · GitHub
Skip to content

Commit

Permalink
fix tests/test_unsupported.py dict_del
Browse files Browse the repository at this point in the history
  • Loading branch information
yilabs authored and adsharma committed Aug 11, 2024
1 parent d2118d4 commit affbf1b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pyd/transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,17 @@ def visit_Tuple(self, node) -> str:
return "({0})".format(elts)

def visit_Delete(self, node) -> str:
self._usings.add("core.memory")
target = node.targets[0]
target_str = self.visit(target)
if len(node.targets) == 1 and isinstance(target, ast.Subscript):
self._usings.add("std.algorithm")
# special handling to delete element from container, e.g.
# tests/test_unsupported.py dict_del: "a = {1: 1}; del a[1]; assert not a",
value = self.visit(target.value)
index = self.visit(target.slice)
return "{0}.remove({1});".format(value, index)

self._usings.add("core.memory")
return (
f"destroy!true({target_str}); core.memory.GC.free(cast(void*){target_str});"
)
Expand Down

0 comments on commit affbf1b

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/py2many/py2many/commit/affbf1b6942a72af62dc6a7be353bb118546d189

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy