Updating Python code to work nicer with Python 2.6
Some time ago I fixed BitBake trunk to not generate DeprecationWarnings when used with Python 2.6. Some time later Richard Purdie backported it into bitbake-1.8 branch. Now I tested it with stable/2009 and want to get it inside.
Patch.bbclass change removes DeprecationWarnings too but has to keep compatibility with Python 2.4 so I had to use try/except block because hashlib is 2.5+
PATCH 1/2 bitbake: Update to work without warnings with python 2.6
From: Richard Purdie <[email protected]>
Some time ago I fixed BitBake trunk to not generate DeprecationWarnings when used with Python 2.6. Some time later Richard Purdie backported it into bitbake-1.8 branch. Now I tested it with stable/2009 and want to get it inside.
--- bitbake/lib/bb/COW.py | 4 ++-- bitbake/lib/bb/cache.py | 3 +-- bitbake/lib/bb/cooker.py | 5 ++--- bitbake/lib/bb/data_smart.py | 5 ++--- bitbake/lib/bb/runqueue.py | 7 +++---- 5 files changed, 10 insertions(+), 14 deletions(-)
bitbake/lib/bb/COW.py +2 -2
@@ -26,7 +26,7 @@ from inspect import getmro import copy -import types, sets +import types types.ImmutableTypes = tuple([ \ types.BooleanType, \ types.ComplexType, \
@@ -35,7 +35,7 @@ types.ImmutableTypes = tuple([ \ types.LongType, \ types.NoneType, \ types.TupleType, \ - sets.ImmutableSet] + \ + frozenset] + \ list(types.StringTypes)) MUTABLE = "__mutable__"
bitbake/lib/bb/cache.py +1 -2
@@ -31,7 +31,6 @@ import os, re import bb.data import bb.utils -from sets import Set try: import cPickle as pickle
@@ -473,6 +472,6 @@ class CacheData: (set elsewhere) """ self.ignored_dependencies = [] - self.world_target = Set() + self.world_target = set() self.bbfile_priority = {} self.bbfile_config_priorities = []
bitbake/lib/bb/cooker.py +2 -3
@@ -25,7 +25,6 @@ import sys, os, getopt, glob, copy, os.path, re, time import bb from bb import utils, data, parse, event, cache, providers, taskdata, runqueue -from sets import Set import itertools, sre_constants parsespin = itertools.cycle( r'|/-\\' )
@@ -485,7 +484,7 @@ class BBCooker: # Tweak some variables item = self.bb_cache.getVar('PN', fn, True) - self.status.ignored_dependencies = Set() + self.status.ignored_dependencies = set() self.status.bbfile_priority[fn] = 1 # Remove external dependencies
@@ -577,7 +576,7 @@ class BBCooker: self.status = bb.cache.CacheData() ignore = bb.data.getVar("ASSUME_PROVIDED", self.configuration.data, 1) or "" - self.status.ignored_dependencies = Set( ignore.split() ) + self.status.ignored_dependencies = set( ignore.split() ) self.handleCollections( bb.data.getVar("BBFILE_COLLECTIONS", self.configuration.data, 1) )
bitbake/lib/bb/data_smart.py +2 -3
@@ -32,7 +32,6 @@ import copy, os, re, sys, time, types import bb from bb import utils, methodpool from COW import COWDictBase -from sets import Set from new import classobj
@@ -142,7 +141,7 @@ class DataSmart: try: self._special_values[keyword].add( base ) except: - self._special_values[keyword] = Set() + self._special_values[keyword] = set() self._special_values[keyword].add( base ) return
@@ -154,7 +153,7 @@ class DataSmart: if '_' in var: override = var[var.rfind('_')+1:] if not self._seen_overrides.has_key(override): - self._seen_overrides[override] = Set() + self._seen_overrides[override] = set() self._seen_overrides[override].add( var ) # setting var
bitbake/lib/bb/runqueue.py +3 -4
@@ -23,7 +23,6 @@ Handles preparation and execution of a queue of tasks # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. from bb import msg, data, event, mkdirhier, utils -from sets import Set import bb, os, sys import signal import stat
@@ -525,8 +524,8 @@ class RunQueue: self.runq_fnid.append(taskData.tasks_fnid[task]) self.runq_task.append(taskData.tasks_name[task]) - self.runq_depends.append(Set(depends)) - self.runq_revdeps.append(Set()) + self.runq_depends.append(set(depends)) + self.runq_revdeps.append(set()) runq_build.append(0)
@@ -622,7 +621,7 @@ class RunQueue: if maps[origdep] == -1: bb.msg.fatal(bb.msg.domain.RunQueue, "Invalid mapping - Should never happen!") newdeps.append(maps[origdep]) - self.runq_depends[listid] = Set(newdeps) + self.runq_depends[listid] = set(newdeps) bb.msg.note(2, bb.msg.domain.RunQueue, "Assign Weightings")
Signature · 1 line
1.6.3
Re: [STABLE][PATCH 1/2] bitbake: Update to work without warnings with python 2.6
Quoted 9 lines · Marcin Juszkiewicz
From: Richard Purdie<[email protected]>
Some time ago I fixed BitBake trunk to not generate DeprecationWarnings when used with Python 2.6. Some time later Richard Purdie backported it into bitbake-1.8 branch. Now I tested it with stable/2009 and want to get it inside.
Signed-off-by Richard Purdie<[email protected]>Signed-off-by Marcin Juszkiewicz<[email protected]>
Otavio Salvador
Acked-byRe: [STABLE][PATCH 1/2] bitbake: Update to work without warnings with python 2.6
Quoted 21 lines · Koen Kooi
Quoted 10 lines · Marcin Juszkiewicz
From: Richard Purdie<[email protected]>
Some time ago I fixed BitBake trunk to not generate DeprecationWarnings when used with Python 2.6. Some time later Richard Purdie backported it into bitbake-1.8 branch. Now I tested it with stable/2009 and want to get it inside.
Signed-off-by Richard Purdie<[email protected]>Signed-off-by Marcin Juszkiewicz<[email protected]>Acked-by Koen Kooi <[email protected]>_______________________________________________
Openembedded-devel mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel
Signature · 3 lines
Otavio Salvador O.S. Systems E-mail: [email protected] http://www.ossystems.com.br Mobile: +55 53 9981-7854 http://projetos.ossystems.com.br
PATCH 2/2 patch.bbclass: use hashlib with Python 2.5+ - removes DeprecationWarning
In reply to Marcin JuszkiewiczPatch.bbclass change removes DeprecationWarnings too but has to keep compatibility with Python 2.4 so I had to use try/except block because hashlib is 2.5+
--- classes/patch.bbclass | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-)
classes/patch.bbclass +10 -2
@@ -13,14 +13,22 @@ def patch_init(d): return "Error: %s not found." % self.path def md5sum(fname): - import md5, sys + import sys + + # when we move to Python 2.5 as minimal supported + # we can kill that try/except as hashlib is 2.5+ + try: + import hashlib + m = hashlib.md5() + except ImportError: + import md5 + m = md5.new() try: f = file(fname, 'rb') except IOError: raise NotFoundError(fname) - m = md5.new() while True: d = f.read(8096) if not d:
Signature · 1 line
1.6.3
Re: [STABLE][PATCH 2/2] patch.bbclass: use hashlib with Python 2.5+ - removes DeprecationWarning
Quoted 5 lines · Marcin Juszkiewicz
Patch.bbclass change removes DeprecationWarnings too but has to keep compatibility with Python 2.4 so I had to use try/except block because hashlib is 2.5+
Signed-off-by Marcin Juszkiewicz<[email protected]>
Otavio Salvador
Acked-byRe: [STABLE][PATCH 2/2] patch.bbclass: use hashlib with Python 2.5+ - removes DeprecationWarning
Quoted 16 lines · Koen Kooi
Quoted 6 lines · Marcin Juszkiewicz
Patch.bbclass change removes DeprecationWarnings too but has to keep compatibility with Python 2.4 so I had to use try/except block because hashlib is 2.5+
Signed-off-by Marcin Juszkiewicz<[email protected]>Acked-by Koen Kooi <[email protected]>_______________________________________________
Openembedded-devel mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel
Signature · 3 lines
Otavio Salvador O.S. Systems E-mail: [email protected] http://www.ossystems.com.br Mobile: +55 53 9981-7854 http://projetos.ossystems.com.br
Quoted 8 lines · Marcin Juszkiewicz
Some time ago I fixed BitBake trunk to not generate DeprecationWarnings when used with Python 2.6. Some time later Richard Purdie backported it into bitbake-1.8 branch. Now I tested it with stable/2009 and want to get it inside.
Patch.bbclass change removes DeprecationWarnings too but has to keep compatibility with Python 2.4 so I had to use try/except block because hashlib is 2.5+
Less users pasting those 'errors' to me is always a good thing :)
regards,
KOen