summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain <syt@logilab.fr>2006-09-23 12:19:11 +0200
committerSylvain <syt@logilab.fr>2006-09-23 12:19:11 +0200
commitd5264b1525d101164d307422d2a45421496c5832 (patch)
tree8c538fab7e56b03b0751ab86a21ab852289d51b5
parent6116c4e389b2c5c96739945bb96aa45c380cdbcc (diff)
downloadastroid-d5264b1525d101164d307422d2a45421496c5832.tar.gz
python 2.5 support, patch provided by Marien Zwart
-rw-r--r--ChangeLog3
-rw-r--r--__pkginfo__.py4
-rw-r--r--raw_building.py38
-rw-r--r--test/unittest_builder.py15
-rw-r--r--test/unittest_inference.py15
5 files changed, 51 insertions, 24 deletions
diff --git a/ChangeLog b/ChangeLog
index 2e51b50..30e6480 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,11 +2,12 @@ Change log for the astng package
================================
--
+ * python 2.5 support, patch provided by Marien Zwart
* fix [Class|Module].block_range method (this fixes pylint's inline
disabling of messages on classes/modules)
* handle class.__bases__ and class.__mro__ (proper metaclass handling
still needed though)
- * drop python2.2 support remove code that was working around python2.2
+ * drop python2.2 support: remove code that was working around python2.2
2006-04-19 -- 0.16.0
* fix living object building to consider classes such as property as
diff --git a/__pkginfo__.py b/__pkginfo__.py
index 2846a77..03b9a09 100644
--- a/__pkginfo__.py
+++ b/__pkginfo__.py
@@ -19,12 +19,10 @@
logilab.astng packaging information
"""
-__revision__ = "$Id: __pkginfo__.py,v 1.12 2006-04-19 14:31:37 syt Exp $"
-
modname = 'astng'
numversion = (0, 16, 0)
version = '.'.join([str(num) for num in numversion])
-pyversions = ["2.3", "2.4"]
+pyversions = ["2.3", "2.4", "2.5"]
license = 'GPL'
copyright = '''Copyright (c) 2003-2006 LOGILAB S.A. (Paris, FRANCE).
diff --git a/raw_building.py b/raw_building.py
index d00fdfb..1dadbc4 100644
--- a/raw_building.py
+++ b/raw_building.py
@@ -21,8 +21,7 @@
:contact: mailto:thenault@gmail.com
"""
-__revision__ = "$Id: raw_building.py,v 1.12 2006-03-05 14:44:15 syt Exp $"
-__doctype__ = "restructuredtext en"
+__docformat__ = "restructuredtext en"
import sys
from inspect import getargspec
@@ -46,13 +45,23 @@ def attach_const_node(node, name, value):
node with the specified name
"""
_attach_local_node(node, nodes.Const(value), name)
-
-def attach_import_node(node, modname, membername):
- """create a From node and register it in the locals of the given
- node with the specified name
- """
- _attach_local_node(node, nodes.From(modname, ( (membername, None), ) ),
- membername)
+
+if sys.version_info < (2, 5):
+ def attach_import_node(node, modname, membername):
+ """create a From node and register it in the locals of the given
+ node with the specified name
+ """
+ _attach_local_node(node,
+ nodes.From(modname, ( (membername, None), ) ),
+ membername)
+else:
+ def attach_import_node(node, modname, membername):
+ """create a From node and register it in the locals of the given
+ node with the specified name
+ """
+ _attach_local_node(node,
+ nodes.From(modname, ( (membername, None), ), 0),
+ membername)
def _attach_local_node(parent, node, name):
node.name = name # needed by add_local_node
@@ -134,9 +143,14 @@ def build_attr_assign(name, value, attr='self'):
return nodes.Assign([nodes.AssAttr(nodes.Name(attr), name, 'OP_ASSIGN')],
nodes.Const(value))
-def build_from_import(fromname, names):
- """create and intialize an astng From import statement"""
- return nodes.From(fromname, [(name, None) for name in names])
+if sys.version_info < (2, 5):
+ def build_from_import(fromname, names):
+ """create and intialize an astng From import statement"""
+ return nodes.From(fromname, [(name, None) for name in names])
+else:
+ def build_from_import(fromname, names):
+ """create and intialize an astng From import statement"""
+ return nodes.From(fromname, [(name, None) for name in names], 0)
def register_arguments(node, args):
"""add given arguments to local
diff --git a/test/unittest_builder.py b/test/unittest_builder.py
index 93887e7..d4f7b5e 100644
--- a/test/unittest_builder.py
+++ b/test/unittest_builder.py
@@ -16,9 +16,8 @@ Copyright (c) 2003-2005 LOGILAB S.A. (Paris, FRANCE).
http://www.logilab.fr/ -- mailto:contact@logilab.fr
"""
-__revision__ = "$Id: unittest_builder.py,v 1.20 2006-04-19 14:31:41 syt Exp $"
-
import unittest
+import sys
from os.path import join, abspath
from logilab.common.testlib import TestCase, unittest_main
@@ -88,9 +87,15 @@ class BuilderTC(TestCase):
import exceptions
builtin_astng = self.builder.inspect_build(exceptions)
fclass = builtin_astng['OSError']
- self.assert_('errno' in fclass.instance_attrs)
- self.assert_('strerror' in fclass.instance_attrs)
- self.assert_('filename' in fclass.instance_attrs)
+ # things like OSError.strerror are now (2.5) data descriptors on the
+ # class instead of entries in the __dict__ of an instance
+ if sys.version_info < (2, 5):
+ container = fclass.instance_attrs
+ else:
+ container = fclass
+ self.assert_('errno' in container)
+ self.assert_('strerror' in container)
+ self.assert_('filename' in container)
def test_package_name(self):
"""test base properties and method of a astng module"""
diff --git a/test/unittest_inference.py b/test/unittest_inference.py
index a87af0a..0a06f81 100644
--- a/test/unittest_inference.py
+++ b/test/unittest_inference.py
@@ -16,8 +16,7 @@ Copyright (c) 2005-2006 LOGILAB S.A. (Paris, FRANCE).
http://www.logilab.fr/ -- mailto:contact@logilab.fr
"""
-__revision__ = "$Id: unittest_inference.py,v 1.20 2006-04-19 15:17:41 syt Exp $"
-
+import sys
from os.path import join, abspath
from logilab.astng import builder, nodes, inference, utils, YES, Instance
@@ -309,7 +308,10 @@ def f():
nie = names.next().infer().next()
self.failUnless(isinstance(nie, nodes.Class))
nie_ancestors = [c.name for c in nie.ancestors()]
- self.failUnlessEqual(nie_ancestors, ['RuntimeError', 'StandardError', 'Exception'])
+ if sys.version_info < (2, 5):
+ self.failUnlessEqual(nie_ancestors, ['RuntimeError', 'StandardError', 'Exception'])
+ else:
+ self.failUnlessEqual(nie_ancestors, ['RuntimeError', 'StandardError', 'Exception', 'BaseException', 'object'])
def test_except_inference(self):
data = '''
@@ -434,6 +436,13 @@ class Warning(Warning):
ancestor = ancestors.next()
self.failUnlessEqual(ancestor.name, 'Exception')
self.failUnlessEqual(ancestor.root().name, 'exceptions')
+ if sys.version_info >= (2, 5):
+ ancestor = ancestors.next()
+ self.failUnlessEqual(ancestor.name, 'BaseException')
+ self.failUnlessEqual(ancestor.root().name, 'exceptions')
+ ancestor = ancestors.next()
+ self.failUnlessEqual(ancestor.name, 'object')
+ self.failUnlessEqual(ancestor.root().name, '__builtin__')
self.failUnlessRaises(StopIteration, ancestors.next)
def test_qqch(self):