pabigot / pyxb

Python XML Schema Bindings
Apache License 2.0
130 stars 75 forks source link

creating an instance of a union does not name the actual type in the resulting exception #127

Open apexo opened 4 years ago

apexo commented 4 years ago

https://github.com/pabigot/pyxb/blob/14737c23a125fd12c954823ad64fc4497816fae3/pyxb/binding/basis.py#L1295-L1296

Because in __new__ the first argument is actually the class (of which an instance is to be constructed), so if we actually want this message to be helpful, it should probably look like this (i.e.: without the .__class__):

raise pyxb.LogicError('%s: cannot construct instances of union' % (self.__name__,)) 

… otherwise the message will always be "type: cannot construct instance of union"