claudevdm commented on code in PR #35904:
URL: https://github.com/apache/beam/pull/35904#discussion_r2433380786


##########
sdks/python/apache_beam/internal/pickler_test.py:
##########
@@ -302,6 +302,48 @@ def test_disable_best_effort_determinism(self):
         dumps(set1, enable_best_effort_determinism=False),
         dumps(set2, enable_best_effort_determinism=False))
 
+  def test_stable_identifier_uses_current_code(self):
+    pickler.set_library('cloudpickle')
+
+    # Get original dynamic function
+    func_v1 = module_test.mutable_test_function()
+
+    pickled_stable = pickler.dumps(
+        func_v1, enable_stable_code_identifier_pickling=True)
+
+    pickled_frozen = pickler.dumps(
+        func_v1, enable_stable_code_identifier_pickling=False)
+
+    # Save original function for cleanup
+    original_function = module_test.mutable_test_function
+
+    try:
+      # Monkey patch: Replace the entire outer function with v2
+      code_v2 = """
+def mutable_test_function():

Review Comment:
   Replace with
   ```
         code_v2 = textwrap.dedent("""
         def mutable_test_function():
           def dynamic_function():
             return "version2"
   
         return dynamic_function
         """)
   ```
   
   Also `import textwrap` into the pickler_test.py file



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to