#3940 closed defect (fixed)
MapScript classObj Error
Reported by: | geographika | Owned by: | unicoletti |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | MapScript-Python | Version: | svn-trunk (development) |
Severity: | major | Keywords: | mapscript python swig |
Cc: | rblazek |
Description
The following code
>>> import mapscript >>> new_class = mapscript.classObj()
using the Python SWIG bindings version 1.3.39 produces this error:
Traceback (most recent call last): File "<pyshell#1>", line 1, in <module> new_class = mapscript.classObj() File "C:/Mapserver/bin/ms/python\mapscript.py", line 828, in __init__ if args and len(args)!=0: NameError: global name 'args' is not defined
Looking at the MapScript SWIG bindings the args parameter should not be in the constructor:
def __init__(self, layer = None): this = _mapscript.new_classObj(layer) try: self.this.append(this) except: self.this = this if 1: if args and len(args)!=0: self.p_layer=args[0] else: self.p_layer=None
Attachments (3)
Change History (14)
comment:1 by , 13 years ago
comment:2 by , 13 years ago
Keywords: | mapscript python swig added |
---|---|
Severity: | normal → major |
Version: | unspecified → svn-trunk (development) |
This seems to be caused by custom Python code added to the pymodule.i file. In the attached patch I commented this out and the mapscript.py file works again.
comment:3 by , 13 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
I have committed some changes that should fix this issue in r12039 Please report if it's working.
comment:5 by , 12 years ago
Cc: | added |
---|---|
Resolution: | fixed |
Status: | closed → reopened |
I have applied r12039 to 6.0.1 and with Python 2.5 it generates
def __init__(self, *args): this = _mapscript.new_layerObj(*args) try: self.this.append(this) except: self.this = this if 1: if map: self.p_map=map else: self.p_map=None
which obviously gives an error when executed. With Python 2.6 it is OK.
comment:6 by , 12 years ago
As much as I'd like to fix this I don't happen to have python 2.5 on any of my systems and I can't find a way to work around it (ie with conditional processing) and believe me I *did* try.
I'm sorry, but unless someone provides a patch for it I'll have to close it as WONTFIX.
follow-up: 8 comment:7 by , 12 years ago
I have attached a patch which is working with python 2.5 and 2.6. I don't say that it is the best solution.
I believe that WONTFIX should only be used for 'features', i.e. something which is considered by developers to be a correct behaviour. Not for obvious bug.
by , 12 years ago
Attachment: | pymodule.i.patch added |
---|
Support for both python 2.5 and 2.6 (version 6.0.1)
by , 12 years ago
Attachment: | pymodule_patch_against_trunk.patch added |
---|
Patch from rblazek updated against trunk
comment:8 by , 12 years ago
Replying to rblazek:
I have attached a patch which is working with python 2.5 and 2.6. I don't say that it is the best solution.
Have tested your patch on 2.6 and generated a fresh one against trunk. Let me now if it works and I'll push it upstream asap.
I believe that WONTFIX should only be used for 'features', i.e. something which is > considered by developers to be a correct behaviour. Not for obvious bug.
Same issue for layerObj. See http://gis.stackexchange.com/questions/8735/using-mapscript-to-create-a-mapfile-from-scratch for more details.