Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#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)

mapscript_py.patch (960 bytes ) - added by geographika 13 years ago.
Patch to custom Python SWIG file
pymodule.i.patch (1.3 KB ) - added by rblazek 12 years ago.
Support for both python 2.5 and 2.6 (version 6.0.1)
pymodule_patch_against_trunk.patch (1.3 KB ) - added by unicoletti 12 years ago.
Patch from rblazek updated against trunk

Download all attachments as: .zip

Change History (14)

by geographika, 13 years ago

Attachment: mapscript_py.patch added

Patch to custom Python SWIG file

comment:2 by geographika, 13 years ago

Keywords: mapscript python swig added
Severity: normalmajor
Version: unspecifiedsvn-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 unicoletti, 13 years ago

Owner: changed from hobu to unicoletti
Status: newassigned

I have committed some changes that should fix this issue in r12039 Please report if it's working.

comment:4 by unicoletti, 12 years ago

Resolution: fixed
Status: assignedclosed

no news, closing

comment:5 by rblazek, 12 years ago

Cc: rblazek added
Resolution: fixed
Status: closedreopened

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 unicoletti, 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.

comment:7 by rblazek, 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 rblazek, 12 years ago

Attachment: pymodule.i.patch added

Support for both python 2.5 and 2.6 (version 6.0.1)

by unicoletti, 12 years ago

Patch from rblazek updated against trunk

in reply to:  7 comment:8 by unicoletti, 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.

comment:9 by guillaume, 12 years ago

worked for me with python 2.6 Thanks

comment:10 by unicoletti, 12 years ago

Resolution: fixed
Status: reopenedclosed

Committed in r13182

comment:11 by aboudreault, 12 years ago

I've backported the fix in branch 6.0 in r13288.

Note: See TracTickets for help on using tickets.