From 1282ed1684aa79c5d7ab427a4b86f7b7582320c6 Mon Sep 17 00:00:00 2001 From: isc-dchui Date: Mon, 24 Nov 2025 09:43:05 -0500 Subject: [PATCH] Fix issue with [ Language = python ] methods misbehaving with quoted names --- CHANGELOG.md | 5 +++++ cls/TestCoverage/Data/CodeUnit.cls | 4 ++++ .../unit_tests/UnitTest/TestCoverage/Unit/CodeUnit.cls | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1ee4fd..505e9f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [4.1.1] - Unreleased + +### Fixed +- #73: No longer errors when a `[ Language = python ]` method has quoted name like "__iter__" + ## [4.1.0] - 2025-11-13 ### Added diff --git a/cls/TestCoverage/Data/CodeUnit.cls b/cls/TestCoverage/Data/CodeUnit.cls index 543d0f2..d15a598 100644 --- a/cls/TestCoverage/Data/CodeUnit.cls +++ b/cls/TestCoverage/Data/CodeUnit.cls @@ -405,6 +405,10 @@ Method UpdateSourceMap(pSourceNamespace As %String, ByRef pCache) As %Status // %Foo() becomes _Foo() in the Python code unit. Set tCLSMethodNum = pCLSCodeUnit.MethodMap.GetAt($Replace(tMethod,"_","%")) } + If (tCLSMethodNum = "") { + // Special Python methods like __iter__ are stored as "__iter__" (with quotes) in CLS + Set tCLSMethodNum = pCLSCodeUnit.MethodMap.GetAt(""""_tMethod_"""") + } Set tMethodStart = ..MethodMap.GetAt(tMethod) Set tMethodEnd = ..MethodEndMap.GetAt(tMethod) Set tMethodName = tMethod diff --git a/internal/testing/unit_tests/UnitTest/TestCoverage/Unit/CodeUnit.cls b/internal/testing/unit_tests/UnitTest/TestCoverage/Unit/CodeUnit.cls index ba77b0b..8f1a11e 100644 --- a/internal/testing/unit_tests/UnitTest/TestCoverage/Unit/CodeUnit.cls +++ b/internal/testing/unit_tests/UnitTest/TestCoverage/Unit/CodeUnit.cls @@ -164,4 +164,9 @@ ClassMethod PythonWeirdSpacing() [ Language = python ] return [element * 2 for element in x] } +Method "__iter__"() [ Language = python ] +{ + return self +} + }