[Python-modules-team] Bug#657269: python-docutils: emacs mode has (accidentally) self-modifying code

Samuel Bronson naesten at gmail.com
Wed Jan 25 01:25:00 UTC 2012


Package: python-docutils
Version: 0.8.1-4
Severity: important
File: /usr/share/emacs/site-lisp/rst.el

This is the expression for the default value of the customization
setting `rst-adornment-faces-alist':

,----
|   (let ((alist '((t . font-lock-keyword-face)
| 		 (nil . font-lock-keyword-face)))
| 	(i 1))
|     (while (<= i rst-level-face-max)
|       (nconc alist (list (cons i (intern (format "rst-level-%d-face" i)))))
|       (setq i (1+ i)))
|     alist)
`----

According to the elisp manual (which refers to this as "STANDARD"):

,----[ (elisp) Variable Definitions ]
|      The expression STANDARD can be evaluated at various other times,
|      too--whenever the customization facility needs to know OPTION's
|      standard value.  So be sure to use an expression which is harmless
|      to evaluate at any time.  We recommend avoiding backquotes in
|      STANDARD, because they are not expanded when editing the value, so
|      list values will appear to have the wrong structure.
`----

Unfortunately, the expression above is not safe to evaluate more than
once, because it has the side effect of modifying the very data
structure representing the expression. This happens because of the way
it passes the value of a list literal to `nconc', which destructively
modifies its arguments.

You can see the problem by customizing the variable `rst-level-face-max'
to a few different values, then asking customize to show the saved lisp
expression for `rst-adornment-faces-alist' (without having customized
that).

A quick fix would be to use a copy of the literal list, as in the
patch below.


diff -u /usr/share/emacs/site-lisp/rst.el /tmp/buffer-content-21867y0f
--- /usr/share/emacs/site-lisp/rst.el	2011-10-23 17:13:51.000000000 -0400
+++ /tmp/buffer-content-21867y0f	2012-01-24 20:15:38.000000000 -0500
@@ -3275,8 +3275,8 @@
   :set 'rst-set-level-default)
 
 (defcustom rst-adornment-faces-alist
-  (let ((alist '((t . font-lock-keyword-face)
-		 (nil . font-lock-keyword-face)))
+  (let ((alist (copy-list '((t . font-lock-keyword-face)
+			    (nil . font-lock-keyword-face))))
 	(i 1))
     (while (<= i rst-level-face-max)
       (nconc alist (list (cons i (intern (format "rst-level-%d-face" i)))))

Diff finished.  Tue Jan 24 20:15:38 2012


-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.30-1-686 (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages python-docutils depends on:
ii  docutils-common               0.8.1-4    text processing system for reStruc
ii  python                        2.7.2-7    interactive high-level object-orie
ii  python-roman                  0.5-3      module for generating/analyzing Ro
ii  python-support                1.0.14     automated rebuilding support for P

Versions of packages python-docutils recommends:
ii  docutils-doc                 0.8.1-4     text processing system for reStruc
ii  libpaper-utils               1.1.23+nmu1 library for handling paper charact
ii  python-imaging               1.1.7-4     Python Imaging Library
pn  python-lxml                  <none>      (no description available)
pn  python-pygments              <none>      (no description available)

Versions of packages python-docutils suggests:
ii  texlive-lang-french           2009-3     TeX Live: French
ii  texlive-latex-base            2009-8     TeX Live: Basic LaTeX packages
ii  texlive-latex-recommended     2009-8     TeX Live: LaTeX recommended packag
pn  ttf-linux-libertine           <none>     (no description available)

-- no debconf information

-- debsums errors found:
dpkg-query: warning: parsing file '/var/lib/dpkg/status' near line 10854 package 'jhcore':
 missing architecture
dpkg-query: warning: parsing file '/var/lib/dpkg/status' near line 17672 package 'docbook-mathml':
 missing architecture
dpkg-query: warning: parsing file '/var/lib/dpkg/status' near line 22720 package 'apt-show-source':
 missing architecture
dpkg-query: warning: parsing file '/var/lib/dpkg/status' near line 35919 package 'tads2-mode':
 missing architecture
dpkg-query: warning: parsing file '/var/lib/dpkg/status' near line 39027 package 'lambdamoo':
 missing architecture

-- 
Hi! I'm a .signature virus! Copy me into your ~/.signature to help me spread!





More information about the Python-modules-team mailing list