Bug#628484: python-xpcom: 'print' method from nsIWebBrowserPrint doesn't work because it triggers a syntax error
Sascha Silbe
sascha-debian-bugs-foo at silbe.org
Sun May 29 12:55:12 UTC 2011
Package: python-xpcom
Version: 1:0.0~hg20100212-5+1
Severity: normal
When trying to access the 'print' method of the nsIWebBrowserPrint
interface, python-xpcom generates Python code on the fly and fails to
evaluate it because 'print' is a reserved keyword in Python:
(sugar-jhbuild1)sascha.silbe at twin:~$ ./print-bug.py
returning /tmp/prefs.js for key NS_APP_PREFS_50_FILE
GConf Error: Failed to contact configuration server; the most common cause is a missing or misconfigured D-Bus session bus daemon. See http://projects.gnome.org/gconf/ for information. (Details - 1: Server ping error: IDL:omg.org/CORBA/COMM_FAILURE:1.0)
Traceback (most recent call last):
File "./print-bug.py", line 20, in _save_pdf
getattr(print_iface, 'print')
File "/usr/lib/pymodules/python2.6/xpcom/client/__init__.py", line 374, in __getattr__
return getattr(interface, attr)
File "/usr/lib/pymodules/python2.6/xpcom/client/__init__.py", line 466, in __getattr__
unbound_method = BuildMethod(method_info, self._iid_)
File "/usr/lib/pymodules/python2.6/xpcom/client/__init__.py", line 125, in BuildMethod
codeObject = compile(method_code, "<XPCOMObject method '%s'>" % (name,), "exec")
File "<XPCOMObject method 'print'>", line 2
def print(self, Param1, Param2):
^
SyntaxError: invalid syntax
print-bug.py is attached.
In case anyone else gets stuck on the issue, here is how I worked around it:
try:
print_method = getattr(print_iface, 'print')
except SyntaxError:
# HACK: Run-time patch python-xpcom to work around a bug.
# 'print' is a reserved keyword, so it must not occur in generated
# code.
iid = interfaces.nsIWebBrowserPrint
internal_interface = print_iface.__dict__['_interfaces_'][iid]
info = internal_interface.__dict__['_method_infos_']['print']
info.name = 'print_'
print_method = getattr(print_iface, 'print')
-- System Information:
Debian Release: 6.0.1
APT prefers stable
APT policy: (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.32-5-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages python-xpcom depends on:
ii libc6 2.11.2-10 Embedded GNU C Library: Shared lib
ii libnspr4-0d 4.8.6-1 NetScape Portable Runtime Library
ii libpython2.6 2.6.6-8+b1 Shared Python runtime library (ver
ii libstdc++6 4.4.5-8 The GNU Standard C++ Library v3
ii python 2.6.6-3+squeeze6 interactive high-level object-orie
ii python-support 1.0.10 automated rebuilding support for P
ii xulrunner-1.9.2 1.9.2.13-2 XUL + XPCOM application runner
python-xpcom recommends no packages.
python-xpcom suggests no packages.
-- no debconf information
-------------- next part --------------
A non-text attachment was scrubbed...
Name: print-bug.py
Type: text/x-python
Size: 875 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-mozilla-maintainers/attachments/20110529/e05baa5c/attachment.py>
More information about the pkg-mozilla-maintainers
mailing list