[IronPython] FlowDocument XAML syntax highlighting and restructured text

Dino Viehland dinov at microsoft.com
Tue Aug 11 21:16:26 CEST 2009

Michael wrote:
> Nope, no class definitions - it just uses .NET functionality. It's a
> very short bit of code really - 77 lines of which 30 lines are a
> dictionary defining a category mapping.

I looked at this closer looking at all combinations of __new__/__init__
being defined and calling the super class w/ and w/o arguments.  Our
behavior on warnings seems to be correct - we're a little less strict
on when we report errors though which I'll fix.

Did you get no warnings from CPython 2.6?  The one other difference
I've noticed is that CPython seems to only warn once - even when I
replace all of the functions in warnings to get past it's report-once
caching - where we warn multiple times.  I'm inclined to not replicate
the behavior that specifically right now.

    import warnings
except ImportError:
    import _warnings as warnings

def warn_explicit(*args):
    print 'my warn', args
    import sys
    x = sys._getframe(0)
    while x:
        print x.f_code
        x = x.f_back

warnings.warn_explicit = warn_explicit
warnings.warn = warn_explicit
warnings._show_warning = warn_explicit
warnings.showwarning = warn_explicit
import _warnings
_warnings.warn_explicit = warn_explicit
_warnings.warn = warn_explicit
_warnings._show_warning = warn_explicit
_warnings.showwarning = warn_explicit

print 'I warn:'
class x(object):
    def __init__(self, *args):
        object.__init__(self, *args)
    def __new__(cls, *args):
        return object.__new__(cls, *args)


print 'I warn once in cpy:'
for i in xrange(2):
    class x(object):
        def __init__(self, *args):
            object.__init__(self, *args)
        def __new__(cls, *args):
            return object.__new__(cls, *args)


More information about the Ironpython-users mailing list