Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-bytecode for openSUSE:Factory 
checked in at 2023-05-28 19:23:33
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-bytecode (Old)
 and      /work/SRC/openSUSE:Factory/.python-bytecode.new.1533 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-bytecode"

Sun May 28 19:23:33 2023 rev:7 rq:1089360 version:0.14.2

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-bytecode/python-bytecode.changes  
2023-04-20 15:15:12.782162731 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-bytecode.new.1533/python-bytecode.changes    
    2023-05-28 19:23:51.337323815 +0200
@@ -1,0 +2,10 @@
+Sat May 27 21:36:54 UTC 2023 - Dirk Müller <[email protected]>
+
+- update to 0.14.2:
+  * allow to convert a CFG, for which stack sizes have not been
+    computed, to Bytecode even in the presence of mergeable
+    TryBegin/TryEnd
+  * remove spurious TryEnd leftover when going from CFG to
+    Bytecode
+
+-------------------------------------------------------------------

Old:
----
  bytecode-0.14.1.tar.gz

New:
----
  bytecode-0.14.2.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-bytecode.spec ++++++
--- /var/tmp/diff_new_pack.4F4XS0/_old  2023-05-28 19:23:52.753332241 +0200
+++ /var/tmp/diff_new_pack.4F4XS0/_new  2023-05-28 19:23:52.757332265 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           python-bytecode
-Version:        0.14.1
+Version:        0.14.2
 Release:        0
 Summary:        Python module to generate and modify bytecode
 License:        MIT

++++++ bytecode-0.14.1.tar.gz -> bytecode-0.14.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/bytecode-0.14.1/PKG-INFO new/bytecode-0.14.2/PKG-INFO
--- old/bytecode-0.14.1/PKG-INFO        2023-04-04 10:03:23.934406500 +0200
+++ new/bytecode-0.14.2/PKG-INFO        2023-05-24 19:44:14.366063000 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: bytecode
-Version: 0.14.1
+Version: 0.14.2
 Summary: Python module to generate and modify bytecode
 Author-email: Victor Stinner <[email protected]>
 Maintainer-email: "Matthieu C. Dartiailh" <[email protected]>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/bytecode-0.14.1/doc/changelog.rst 
new/bytecode-0.14.2/doc/changelog.rst
--- old/bytecode-0.14.1/doc/changelog.rst       2023-04-04 10:03:09.000000000 
+0200
+++ new/bytecode-0.14.2/doc/changelog.rst       2023-05-24 19:44:01.000000000 
+0200
@@ -1,6 +1,16 @@
 ChangeLog
 =========
 
+2023-05-24: Version 0.14.2
+--------------------------
+
+Bugfixes:
+
+- allow to convert a CFG, for which stack sizes have not been computed, to 
Bytecode
+  even in the presence of mergeable TryBegin/TryEnd  PR #120
+- remove spurious TryEnd leftover when going from CFG to Bytecode  PR #120
+
+
 2023-04-04: Version 0.14.1
 --------------------------
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/bytecode-0.14.1/src/bytecode/cfg.py 
new/bytecode-0.14.2/src/bytecode/cfg.py
--- old/bytecode-0.14.1/src/bytecode/cfg.py     2023-04-04 10:03:09.000000000 
+0200
+++ new/bytecode-0.14.2/src/bytecode/cfg.py     2023-05-24 19:44:01.000000000 
+0200
@@ -819,8 +819,8 @@
             # - if the current instruction is a TryEnd and if the last 
instruction
             #   is final in which case we insert the TryEnd in the old block.
             # - if we have a currently active TryBegin for which we may need to
-            #   create a TryEnd in the previous and a new TryBegin in the new 
one
-            #   because the blocks are not connected.
+            #   create a TryEnd in the previous block and a new TryBegin in the
+            #   new one because the blocks are not connected.
             if old_block is not None:
                 temp = try_begin_inserted_in_block
                 try_begin_inserted_in_block = False
@@ -981,7 +981,8 @@
 
                         # If the TryBegin share the target and push_lasti of 
the
                         # entry of an adjacent TryEnd, omit the new TryBegin 
that
-                        # was inserted to allow analysis of the CFG
+                        # was inserted to allow analysis of the CFG and remove
+                        # the already inserted TryEnd.
                         if last_try_end is not None:
                             cfg_te, byt_te = last_try_end
                             entry = cfg_te.entry
@@ -989,10 +990,17 @@
                                 entry.target is instr.target
                                 and entry.push_lasti == instr.push_lasti
                             ):
-                                byt_te.entry.stack_depth = min(
-                                    entry.stack_depth, instr.stack_depth
-                                )
+                                # If we did not yet compute the required stack 
depth
+                                # keep the value as UNSET
+                                if entry.stack_depth is UNSET:
+                                    assert instr.stack_depth is UNSET
+                                    byt_te.entry.stack_depth = UNSET
+                                else:
+                                    byt_te.entry.stack_depth = min(
+                                        entry.stack_depth, instr.stack_depth
+                                    )
                                 try_begins[instr] = byt_te.entry
+                                instructions.remove(byt_te)
                                 continue
                         assert isinstance(new, TryBegin)
                         try_begins[instr] = new
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/bytecode-0.14.1/src/bytecode/version.py 
new/bytecode-0.14.2/src/bytecode/version.py
--- old/bytecode-0.14.1/src/bytecode/version.py 2023-04-04 10:03:23.000000000 
+0200
+++ new/bytecode-0.14.2/src/bytecode/version.py 2023-05-24 19:44:14.000000000 
+0200
@@ -5,7 +5,7 @@
 #: A namedtuple of the version info for the current release.
 _version_info = namedtuple("_version_info", "major minor micro status")
 
-parts = "0.14.1".split(".", 3)
+parts = "0.14.2".split(".", 3)
 version_info = _version_info(
     int(parts[0]),
     int(parts[1]),
@@ -16,4 +16,4 @@
 # Remove everything but the 'version_info' from this module.
 del namedtuple, _version_info, parts
 
-__version__ = "0.14.1"
+__version__ = "0.14.2"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/bytecode-0.14.1/src/bytecode.egg-info/PKG-INFO 
new/bytecode-0.14.2/src/bytecode.egg-info/PKG-INFO
--- old/bytecode-0.14.1/src/bytecode.egg-info/PKG-INFO  2023-04-04 
10:03:23.000000000 +0200
+++ new/bytecode-0.14.2/src/bytecode.egg-info/PKG-INFO  2023-05-24 
19:44:14.000000000 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: bytecode
-Version: 0.14.1
+Version: 0.14.2
 Summary: Python module to generate and modify bytecode
 Author-email: Victor Stinner <[email protected]>
 Maintainer-email: "Matthieu C. Dartiailh" <[email protected]>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/bytecode-0.14.1/tests/test_cfg.py 
new/bytecode-0.14.2/tests/test_cfg.py
--- old/bytecode-0.14.1/tests/test_cfg.py       2023-04-04 10:03:09.000000000 
+0200
+++ new/bytecode-0.14.2/tests/test_cfg.py       2023-05-24 19:44:01.000000000 
+0200
@@ -4,6 +4,7 @@
 import inspect
 import io
 import sys
+import textwrap
 import types
 import unittest
 
@@ -874,6 +875,20 @@
         self.assertEqual(test.__code__.co_stacksize, 1)
         self.assertEqual(test(1), 0)
 
+    def test_stack_size_with_dead_code2(self):
+        # See GH #118
+        source = """
+        try:
+            pass
+        except Exception as e:
+            pass
+        """
+        source = textwrap.dedent(source).strip()
+        code = compile(source, "<string>", "exec")
+        bytecode = Bytecode.from_code(code)
+        cfg = ControlFlowGraph.from_bytecode(bytecode)
+        cfg.to_bytecode()
+
     def test_huge_code_with_numerous_blocks(self):
         def base_func(x):
             pass

Reply via email to