Getting TypeError in Changing file permissions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pranav Bagora

    #1

    Getting TypeError in Changing file permissions

    Hello ,
    i am trying to change mode of files using the
    os.chmod()funct ion. But i am getting an error

    " os.chmod(outfil e,0700)
    TypeError: coercing to Unicode: need string or buffer,
    file found"

    Please Help,
    Pranav

    _______________ _______________ _______________ _____
    Do You Yahoo!?
    Tired of spam? Yahoo! Mail has the best spam protection around
    Yahoo Mail: Your smarter, faster, free email solution. Organize your inbox, protect your privacy, and tackle tasks efficiently with AI-powered features and robust security tools.

  • Benjamin Niemann

    #2
    Re: Getting TypeError in Changing file permissions

    Pranav Bagora wrote:
    [color=blue]
    > Hello ,
    > i am trying to change mode of files using the
    > os.chmod()funct ion. But i am getting an error
    >
    > " os.chmod(outfil e,0700)
    > TypeError: coercing to Unicode: need string or buffer,
    > file found"[/color]

    Looks as if your are using a file object (that you got from an open() call)
    as the first parameter. What you need is a string with the path to the
    file.

    --
    Benjamin Niemann
    Email: pink at odahoda dot de
    WWW: http://www.odahoda.de/

    Comment

    • Peter Hansen

      #3
      Re: Getting TypeError in Changing file permissions

      Benjamin Niemann wrote:[color=blue]
      > Pranav Bagora wrote:[color=green]
      >>" os.chmod(outfil e,0700)
      >>TypeError: coercing to Unicode: need string or buffer,
      >>file found"[/color]
      >
      > Looks as if your are using a file object (that you got from an open() call)
      > as the first parameter. What you need is a string with the path to the
      > file.[/color]

      Which this should do:

      os.chmod(outfil e.name, 0700)

      -Peter

      Comment

      Working...