Hello community,

here is the log from the commit of package python-Chameleon for 
openSUSE:Factory checked in at 2020-06-09 00:05:39
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-Chameleon (Old)
 and      /work/SRC/openSUSE:Factory/.python-Chameleon.new.3606 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-Chameleon"

Tue Jun  9 00:05:39 2020 rev:10 rq:812491 version:3.7.2

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-Chameleon/python-Chameleon.changes        
2020-04-18 00:32:24.974299036 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-Chameleon.new.3606/python-Chameleon.changes  
    2020-06-09 00:07:30.509896107 +0200
@@ -1,0 +2,7 @@
+Mon Jun  8 09:03:16 UTC 2020 - Ondřej Súkup <mimi...@gmail.com>
+
+- Update to 3.7.2
+ * Fix compatiblity issue with Python 3.9.
+ * Allow setting a custom value representation function
+
+-------------------------------------------------------------------

Old:
----
  Chameleon-3.7.0.tar.gz

New:
----
  Chameleon-3.7.2.tar.gz

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

Other differences:
------------------
++++++ python-Chameleon.spec ++++++
--- /var/tmp/diff_new_pack.bocEx0/_old  2020-06-09 00:07:32.205902124 +0200
+++ /var/tmp/diff_new_pack.bocEx0/_new  2020-06-09 00:07:32.209902138 +0200
@@ -18,7 +18,7 @@
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-Chameleon
-Version:        3.7.0
+Version:        3.7.2
 Release:        0
 Summary:        Fast HTML/XML Template Compiler
 License:        BSD-3-Clause AND BSD-4-Clause AND Python-2.0 AND ZPL-2.1

++++++ Chameleon-3.7.0.tar.gz -> Chameleon-3.7.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chameleon-3.7.0/CHANGES.rst 
new/chameleon-3.7.2/CHANGES.rst
--- old/chameleon-3.7.0/CHANGES.rst     2020-03-26 07:46:32.000000000 +0100
+++ new/chameleon-3.7.2/CHANGES.rst     2020-05-31 07:51:18.000000000 +0200
@@ -1,6 +1,18 @@
 Changes
 =======
 
+3.7.2 (2020-05-31)
+------------------
+
+- Allow setting a custom value representation function, allowing
+  custom formatting of variables during exception formatting.
+
+3.7.1 (2020-05-10)
+------------------
+
+- Fix compatiblity issue with Python 3.9.
+
+
 3.7.0 (2020-03-26)
 ------------------
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chameleon-3.7.0/MANIFEST.in 
new/chameleon-3.7.2/MANIFEST.in
--- old/chameleon-3.7.0/MANIFEST.in     2020-03-26 07:46:32.000000000 +0100
+++ new/chameleon-3.7.2/MANIFEST.in     2020-05-31 07:51:18.000000000 +0200
@@ -1,5 +1,4 @@
 global-exclude tests/*.py
-recursive-exclude src/chameleon/tests
 exclude MANIFEST.in
 exclude *.rst
 include LICENSE.txt
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chameleon-3.7.0/setup.py new/chameleon-3.7.2/setup.py
--- old/chameleon-3.7.0/setup.py        2020-03-26 07:46:32.000000000 +0100
+++ new/chameleon-3.7.2/setup.py        2020-05-31 07:51:18.000000000 +0200
@@ -1,4 +1,4 @@
-__version__ = '3.7.0'
+__version__ = '3.7.2'
 
 import os
 
@@ -51,6 +51,7 @@
        "Programming Language :: Python :: 3.6",
        "Programming Language :: Python :: 3.7",
        "Programming Language :: Python :: 3.8",
+       "Programming Language :: Python :: 3.9",
        "Programming Language :: Python :: Implementation :: CPython",
        "Programming Language :: Python :: Implementation :: PyPy",
       ],
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chameleon-3.7.0/src/chameleon/astutil.py 
new/chameleon-3.7.2/src/chameleon/astutil.py
--- old/chameleon-3.7.0/src/chameleon/astutil.py        2020-03-26 
07:46:32.000000000 +0100
+++ new/chameleon-3.7.2/src/chameleon/astutil.py        2020-05-31 
07:51:18.000000000 +0200
@@ -123,7 +123,8 @@
     target.__dict__ = source.__dict__
 
 
-def swap(root, replacement, name):
+def swap(body, replacement, name):
+    root = ast.Expression(body=body)
     for node in ast.walk(root):
         if (isinstance(node, ast.Name) and
             isinstance(node.ctx, ast.Load) and
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chameleon-3.7.0/src/chameleon/compiler.py 
new/chameleon-3.7.2/src/chameleon/compiler.py
--- old/chameleon-3.7.0/src/chameleon/compiler.py       2020-03-26 
07:46:32.000000000 +0100
+++ new/chameleon-3.7.2/src/chameleon/compiler.py       2020-05-31 
07:51:18.000000000 +0200
@@ -1306,8 +1306,8 @@
 
         # Visit body to generate the message body
         code = self.visit(node.node)
-        swap(ast.Suite(body=code), load(append), "__append")
-        swap(ast.Suite(body=code), load(stream), "__stream")
+        swap(code, load(append), "__append")
+        swap(code, load(stream), "__stream")
         body += code
 
         # Reduce white space and assign as message id
@@ -1545,7 +1545,7 @@
 
         # generate code
         code = self.visit(node.node)
-        swap(ast.Suite(body=code), load(append), "__append")
+        swap(code, load(append), "__append")
         body += code
 
         # output msgid
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chameleon-3.7.0/src/chameleon/exc.py 
new/chameleon-3.7.2/src/chameleon/exc.py
--- old/chameleon-3.7.0/src/chameleon/exc.py    2020-03-26 07:46:32.000000000 
+0100
+++ new/chameleon-3.7.2/src/chameleon/exc.py    2020-05-31 07:51:18.000000000 
+0200
@@ -3,7 +3,6 @@
 import traceback
 
 from .utils import create_formatted_exception
-from .utils import format_kwargs
 from .utils import safe_native
 from .tokenize import Token
 from .config import SOURCE_EXPRESSION_MARKER_LENGTH as LENGTH
@@ -256,7 +255,7 @@
 
 
 class ExceptionFormatter(object):
-    def __init__(self, errors, econtext, rcontext):
+    def __init__(self, errors, econtext, rcontext, value_repr):
         kwargs = rcontext.copy()
         kwargs.update(econtext)
 
@@ -266,18 +265,15 @@
 
         self._errors = errors
         self._kwargs = kwargs
+        self._value_repr = value_repr
 
     def __call__(self):
         # Format keyword arguments; consecutive arguments are indented
         # for readability
-        try:
-            formatted = format_kwargs(self._kwargs)
-        except:
-            # the ``pprint.pformat`` method calls the representation
-            # method of the arguments; this may fail and since we're
-            # already in an exception handler, there's no point in
-            # pursuing this further
-            formatted = ()
+        formatted = [
+            "%s: %s" % (name, self._value_repr(value))
+            for name, value in self._kwargs.items()
+        ]
 
         for index, string in enumerate(formatted[1:]):
             formatted[index + 1] = " " * 15 + string
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chameleon-3.7.0/src/chameleon/template.py 
new/chameleon-3.7.2/src/chameleon/template.py
--- old/chameleon-3.7.0/src/chameleon/template.py       2020-03-26 
07:46:32.000000000 +0100
+++ new/chameleon-3.7.2/src/chameleon/template.py       2020-05-31 
07:51:18.000000000 +0200
@@ -56,6 +56,7 @@
 from .utils import read_bytes
 from .utils import raise_with_traceback
 from .utils import byte_string
+from .utils import value_repr
 
 
 log = logging.getLogger('chameleon.template')
@@ -125,6 +126,10 @@
     # time. When not set, this is only required at evaluation time.
     strict = True
 
+    # This should return a value string representation for exception
+    # formatting.
+    value_repr = staticmethod(value_repr)
+
     def __init__(self, body=None, **config):
         self.__dict__.update(config)
 
@@ -197,7 +202,7 @@
                         formatter._errors.extend(errors)
                     raise
 
-                formatter = ExceptionFormatter(errors, econtext, rcontext)
+                formatter = ExceptionFormatter(errors, econtext, rcontext, 
self.value_repr)
 
                 try:
                     exc = create_formatted_exception(
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chameleon-3.7.0/src/chameleon/utils.py 
new/chameleon-3.7.2/src/chameleon/utils.py
--- old/chameleon-3.7.0/src/chameleon/utils.py  2020-03-26 07:46:32.000000000 
+0100
+++ new/chameleon-3.7.2/src/chameleon/utils.py  2020-05-31 07:51:18.000000000 
+0200
@@ -325,24 +325,21 @@
     return s
 
 
-def format_kwargs(kwargs):
-    items = []
-    for name, value in kwargs.items():
-        if isinstance(value, string_type):
-            short = limit_string(value)
-            items.append((name, short.replace('\n', '\\n')))
-        elif isinstance(value, (int, float)):
-            items.append((name, value))
-        elif isinstance(value, dict):
-            items.append((name, '{...} (%d)' % len(value)))
-        else:
-            items.append((name,
-                "<%s %s at %s>" % (
-                    type(value).__name__,
-                    getattr(value, '__name__', "-"),
-                    hex(abs(id(value))))))
+def value_repr(value):
+    if isinstance(value, string_type):
+        short = limit_string(value)
+        return short.replace('\n', '\\n')
+    if isinstance(value, (int, float)):
+        return value
+    if isinstance(value, dict):
+        return '{...} (%d)' % len(value)
 
-    return ["%s: %s" % item for item in items]
+    try:
+        name = str(getattr(value, '__name__', None)),
+    except:
+        name = '-'
+
+    return '<%s %s at %s>' % (type(value).__name__, name, hex(abs(id(value))))
 
 
 class callablestr(str):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chameleon-3.7.0/src/chameleon/zpt/template.py 
new/chameleon-3.7.2/src/chameleon/zpt/template.py
--- old/chameleon-3.7.0/src/chameleon/zpt/template.py   2020-03-26 
07:46:32.000000000 +0100
+++ new/chameleon-3.7.2/src/chameleon/zpt/template.py   2020-05-31 
07:51:18.000000000 +0200
@@ -156,6 +156,13 @@
         None by default. If provided, this tokenizer is used instead of the 
default
         (which is selected based on the template mode parameter.)
 
+      ``value_repr``
+
+        This can be used to override the default value representation
+        function which is used to format values when formatting an
+        exception output. The function must not raise an exception (it
+        should be safe to call with any value).
+
     Output is unicode on Python 2 and string on Python 3.
 
     """


Reply via email to