Python crashed when importing SOAPpy,printing out 'usage:copy source destination'

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jiang.haiyun@gmail.com

    #1

    Python crashed when importing SOAPpy,printing out 'usage:copy source destination'

    Hello all,
    when i import SOAPpy, the python crashed and print out 'usage:copy
    source destination'.
    As follows:
    ############### #############
    haiyun# python
    Python 2.4.1 (#2, Mar 28 2006, 21:00:14)
    [GCC 3.4.2 [FreeBSD] 20040728] on freebsd5
    Type "help", "copyright" , "credits" or "license" for more information.
    >>import SOAPpy
    usage:copy source destination
    ############### ##############
    Then i checked and found that in my pwd there is a .py file,
    i guess it is this file caused the problem.
    the file content is as follows:
    ############### #############
    haiyun# cat a.py
    #!env python
    usage="usage:co py source destination\n"
    import sys
    len=len(sys.arg v)
    if len!=3 :
    print usage
    sys.exit()
    ############### #end#########

    So the python will crash when i import SOAPpy if working in a dir
    containing this .py file,
    and if rename the .py file to another type , say .txt, the problem
    dispeared.

    Who can tell me what's the problem.

  • Fredrik Lundh

    #2
    Re: Python crashed when importing SOAPpy, printing out 'usage:copysour ce destination'

    jiang.haiyun@gm ail.com wrote:
    when i import SOAPpy, the python crashed and print out 'usage:copy
    source destination'.
    As follows:
    ############### #############
    haiyun# python
    Python 2.4.1 (#2, Mar 28 2006, 21:00:14)
    [GCC 3.4.2 [FreeBSD] 20040728] on freebsd5
    Type "help", "copyright" , "credits" or "license" for more information.
    >>>import SOAPpy
    usage:copy source destination
    ############### ##############
    Then i checked and found that in my pwd there is a .py file,
    i guess it is this file caused the problem.
    the file content is as follows:
    ############### #############
    haiyun# cat a.py
    #!env python
    usage="usage:co py source destination\n"
    import sys
    len=len(sys.arg v)
    if len!=3 :
    print usage
    sys.exit()
    ############### #end#########
    >
    So the python will crash when i import SOAPpy if working in a dir
    containing this .py file,
    and if rename the .py file to another type , say .txt, the problem
    dispeared.
    >
    Who can tell me what's the problem.
    this is how things work: Python doesn't distinguish between script
    files and module files; a module is simply a script that defines a
    bunch of things.

    if you want to create something that can work both as a script and a
    module, see:



    </F>

    Comment

    • jiang.haiyun@gmail.com

      #3
      Re: Python crashed when importing SOAPpy, printing out 'usage:copy source destination'

      Fredrik Lundh wrote:
      >
      this is how things work: Python doesn't distinguish between script
      files and module files; a module is simply a script that defines a
      bunch of things.
      >
      if you want to create something that can work both as a script and a
      module, see:
      >

      >
      </F>
      I still can't understand it. If i rename the 'copy.py' to 'a.py',
      there will be no problem.
      As follows:
      ############### ############
      haiyun# ls
      copy.py
      haiyun# python
      Python 2.4.1 (#2, Mar 28 2006, 21:00:14)
      [GCC 3.4.2 [FreeBSD] 20040728] on freebsd5
      Type "help", "copyright" , "credits" or "license" for more information.
      >>import SOAPpy
      usage:copy source destination

      haiyun# ls
      copy.py copy.pyc
      ############### ###########

      it seems that the copy.py in the PWD has been interpreted as the
      SOAPpy module imported.
      So i rename the copy.py to a.py.
      As follows:
      ############### #########
      haiyun# ls
      copy.py copy.pyc
      haiyun# rm copy.pyc
      haiyun# mv copy.py a.py
      haiyun# ls
      a.py
      haiyun# python
      Python 2.4.1 (#2, Mar 28 2006, 21:00:14)
      [GCC 3.4.2 [FreeBSD] 20040728] on freebsd5
      Type "help", "copyright" , "credits" or "license" for more information.
      >>import SOAPpy
      >>>
      ############### ##########

      Everything is all right!
      The content of the copy.py(a.py) is:
      ############### ##########
      haiyun# cat a.py
      #!env python
      usage="usage:co py source destination\n"
      import sys
      len=len(sys.arg v)
      if len!=3 :
      print usage
      sys.exit()
      ############### ##########

      I guess something in the SOAPpy module conflects with the copy.py in
      the PWD.
      So what it happened?
      >Regards,
      >jiang.haiyun

      Comment

      • Fredrik Lundh

        #4
        Re: Python crashed when importing SOAPpy, printing out 'usage:copysour ce destination'

        jiang.haiyun@gm ail.com wrote:
        I still can't understand it. If i rename the 'copy.py' to 'a.py',
        there will be no problem.
        hint: when it works, try typing the following into the interpreter:
        >>import copy
        >>copy.__file __
        </F>

        Comment

        • jiang.haiyun@gmail.com

          #5
          Re: Python crashed when importing SOAPpy, printing out 'usage:copy source destination'

          Fredrik Lundh wrote:
          jiang.haiyun@gm ail.com wrote:
          >
          I still can't understand it. If i rename the 'copy.py' to 'a.py',
          there will be no problem.
          >
          hint: when it works, try typing the following into the interpreter:
          >
          >>import copy
          >>copy.__file __
          >
          </F>
          I know, the copy module is imported by the SOAPpy module.
          But SOAPpy imported an un-proper one from the CWD.

          Thank you very much :)
          >Regards,
          >jiang.haiyun

          Comment

          Working...