[IronPython] TypeError: unbound method open must be called with ....

Dino Viehland dinov at exchange.microsoft.com
Mon Mar 20 17:27:24 CET 2006


If I do this in CPython I get the same result:

Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information. >>> import webbrowser
>>> webbrowser.WindowsDefault.open("http://www.microsoft.com")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: unbound method open() must be called with WindowsDefault instance as first argument (got str instance instead)


What is happening is that you're performing an instance call w/o an instance.  What I belive you want is:

webbrowser.open("http://www.microsoft.com")

which also doesn't work in IronPython but for a different reason:

Traceback (most recent call last):
  File , line 0, in input##631
  File C:\Python24\Lib\webbrowser.py, line 46, in open_new
  File C:\Python24\Lib\webbrowser.py, line 38, in get
Error: could not locate runnable browser

That happens because cli isn't a recognized module name (and therefore we don't register WindowsDefault)...  You can fix that:

webbrowser._tryorder = ["windows-default"]
webbrowser.register('windows-default',webbrowser.WindowsDefault)

but then we finally blow up because we don't support startfile on the os module:

>>> webbrowser.open_new('http://www.microsoft.com')
Traceback (most recent call last):
  File , line 0, in input##669
  File C:\Python24\Lib\webbrowser.py, line 46, in open_new
  File C:\Python24\Lib\webbrowser.py, line 250, in open
AttributeError: 'module' object has no attribute 'startfile'

--------------

I'll open a bug that we need to support startfile...  the platform issue is a more difficult one as our platform is really "cli".  So what to do for this one isn't entirely clear...




Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038)

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of JoeSox
Sent: Sunday, March 19, 2006 7:09 PM
To: Discussion of IronPython
Subject: [IronPython] TypeError: unbound method open must be called with ....

Hi,

Can someone possibly explain to me what is going on with the TypeError below?
I've tried the same calls in IDLE and it works.  Correct me if I am
wrong but webbrowser.py only uses os and sys. I don't understand what
<class webbrowser.WindowsDefault at 0x000000000000002B>
means. Thanks.

======
IronPython 1.0.2262 (Beta) on .NET 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
>>> import sys
>>> sys.path.append("C:\Python24\Tools\Scripts")
>>> sys.path.append("C:\Python24\Lib")
>>> import webbrowser
>>> webbrowser.WindowsDefault.open("http://www.microsoft.com")
Traceback (most recent call last):
  File , line 0, in input##399
TypeError: unbound method open must be called with <class
webbrowser.WindowsDefault at 0x000000000000002B> instance as first
argument (got str instance instead)
>>>
======

--
Joseph
_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com



More information about the Ironpython-users mailing list