Make encoding header Emacs friendly

Bug #1324686 reported by Martin Geisler
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ceilometer
Fix Released
Low
Martin Geisler
python-ceilometerclient
Fix Released
Low
Unassigned

Bug Description

The file encoding line serves a dual purpose: it informs both Python
and Emacs about the file encoding.

PEP 263 explains that a file with non-ASCII characters must specify an
encoding. Without an encoding line, importing the file will raise a
SyntaxError.

The problem is now that while Python will accept both of

  -*- encoding: <some-encoding> -*-
  -*- coding: <some-encoding> -*-

whereas Emacs only accepts the latter since it looks for a file
variable named "coding", not "encoding".

Setting a variable called "encoding" has at best no effect, but it can
result in Emacs prompting the user with

  The local variable list in __init__.py contains values that may not
  be safe.

when opening the file. This is because the "encoding" variable is not
whitelisted as a safe variable.

I've opened reviews for patches fixing this here:

https://review.openstack.org/95863/
https://review.openstack.org/95880/

Revision history for this message
gordon chung (chungg) wrote :

thanks for explanation. i have preference to remove that line... if not possible, then the change is fine with me.

Changed in ceilometer:
status: New → Triaged
Changed in python-ceilometerclient:
status: New → Triaged
Changed in ceilometer:
importance: Undecided → Low
Changed in python-ceilometerclient:
importance: Undecided → Low
Revision history for this message
Martin Geisler (mgeisler) wrote :

Great, I'll rework the patches so they remove the line were possible (where the file doesn't contain Unicode characters).

Revision history for this message
Martin Geisler (mgeisler) wrote :

I've updated

* https://review.openstack.org/96117/ for ceilometer
* https://review.openstack.org/95880/ for python-ceilometer

so that the copyright symbols are removed and the now unnecessary coding lines are dropped.

This is the approach I used for Tuskar (https://review.openstack.org/96123/). Please let me know what you think :-)

Changed in ceilometer:
assignee: nobody → Martin Geisler (mgeisler)
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to ceilometer (master)

Reviewed: https://review.openstack.org/96117
Committed: https://git.openstack.org/cgit/openstack/ceilometer/commit/?id=d7054053ae1f0dad276279bdf66c622842fec1be
Submitter: Jenkins
Branch: master

commit d7054053ae1f0dad276279bdf66c622842fec1be
Author: Martin Geisler <email address hidden>
Date: Wed May 28 11:31:52 2014 +0200

    Remove (c) and remove unnecessary encoding lines

    The word "Copyright" alone is sufficient to claim copyright, the (c)
    symbol need not be present.[1]

    As per PEP 263, a Python file with non-ASCII characters must have a
    line with "coding: <some-encoding>". Python files containing only
    7-bit ASCII characters need no such line.[2]

    This commit removes unnecessary Unicode copyright symbols and
    unnecessary encoding lines.

    [1]: http://www.copyright.gov/circs/circ03.pdf
    [2]: http://legacy.python.org/dev/peps/pep-0263/

    Closes-Bug: #1324686
    Change-Id: Id381ea1f029a0cfddd3773c6d9f16c47842d9c33

Changed in ceilometer:
status: In Progress → Fix Committed
Eoghan Glynn (eglynn)
Changed in ceilometer:
milestone: none → juno-1
Thierry Carrez (ttx)
Changed in ceilometer:
status: Fix Committed → Fix Released
Revision history for this message
Dina Belova (dbelova) wrote :

Sorry, wanted to pick "fix committed" for the python-ceilometerclient - the fix has been merged to the upstream, but there was no client release since that time

Changed in python-ceilometerclient:
status: Triaged → Fix Released
Thierry Carrez (ttx)
Changed in ceilometer:
milestone: juno-1 → 2014.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.