RowClassFactory: __slots__ must be identifiers

Bug #98473 reported by Maciej Wisniowski
2
Affects Status Importance Assigned to Milestone
Zope 3
Won't Fix
Low
Unassigned
zope.rdb
Confirmed
Low
Unassigned

Bug Description

Zope3.3.0 with cx_Oracle adapter
I've used typical Oracle statement:

select 1 from dual

I've received error:
TypeError: __slots__ must be identifiers

The problem is with RowClassFactory defined
in zope/rdb/__init__.py that assumes that column
names are valid python identifiers.

There is current implementation of RowClassFactory:

def RowClassFactory(columns):
 """Creates a Row object"""
 klass_namespace = {}
 klass_namespace['__Security_checker__'] = InstanceOnlyDescriptor(
     NamesChecker(columns))
 klass_namespace['__slots__'] = tuple(columns)

 return type('GeneratedRowClass', (Row,), klass_namespace)

in my case:

klass_namespace is {'__slots__':('1',)}

and '1' causes error.

select 1 as abc from dual executes correctly.

For me, I've implemented temporary solution that simply changes
the names of numeric attributes (like '1') to prefixed ones
(like '_1').

I think there should be a kind of parser that converts
column names to valid python identifiers or different
implementation that doesn't use class attributes to store columns
data.

Revision history for this message
Benji York (benji) wrote :

I seem to recall this being reported before and either fixed, or marked as a WONTFIX, but for the life of me, I can't find the original issue.

Revision history for this message
Maciej Wisniowski (pigletto) wrote :

> I seem to recall this being reported before and either fixed, or marked
> as a WONTFIX, but for the life of me, I can't find the original issue.
I've reported this on Zope3-users list:
http://mail.zope.org/pipermail/zope3-users/2006-October/004722.html
I've not submitted this issue to the collector then.

Changed in zope3:
status: New → Confirmed
Tres Seaver (tseaver)
affects: zope.component → zope.rdb
Changed in zope.rdb:
importance: Undecided → Low
status: New → Confirmed
Changed in zope3:
status: Confirmed → Won't Fix
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.