Re: PEP263 and execfile()
From: Mike C. Fletcher (mcfletch_at_rogers.com)
Date: 11/17/03
- Next message: Roman Suzi: "PEP263 and execfile()"
- Previous message: Maxim Olivier-Adlhoch: "socket object, connection refused ..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 17 Nov 2003 14:56:06 -0500 To: Roman Suzi <rnd@onego.ru>
Roman Suzi wrote:
>hi!
>
>One of my old web projects uses execfile alot, because
>its data are stored in Python. How do I suppress
>all those warnings
>
>DeprecationWarning: Non-ASCII character '\xd2' in file ffff.py on line 5,
>but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
>
>in one place (preferably at execfile() call)?
>
>
Ran into the same problem with ResourcePackage (which stores binary data
in Python files). I put a dumb (i.e. solely to shut up the system)
encoding declaration (a (meaningless) declaration that the file use some
arbitrary 8-bit encoding, such as latin-1 so that high-bit characters
are acceptable) at the top of the files (i.e. modified the system to
write those encodings on storage).
In your case you'd need to write a script to fix up all the old files
(luckily they'll all be on your web-server) too.
# -*- coding: ISO-8859-1 -*-
for file in files:
open(file, 'w').write( HEADER+ open(file,'r').read())
(though, of course, you'd want to be a little more careful than that ;) ).
Good luck, and HTH,
Mike
_______________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://members.rogers.com/mcfletch/
- Next message: Roman Suzi: "PEP263 and execfile()"
- Previous message: Maxim Olivier-Adlhoch: "socket object, connection refused ..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|