grotor / pyvk-t

Automatically exported from code.google.com/p/pyvk-t
0 stars 0 forks source link

Не стартует с ошибкой синтаксиса #97

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Вот что вываливает:
python main.py -l pyvkt.log                  
~/temp/pyvk-t-read-only/pyvkt/component.py:578: Warning: 'with' will become a 
reserved keyword in Python 2.6
Traceback (most recent call last):
  File "main.py", line 4, in <module>
    import pyvkt.component
  File "~/temp/pyvk-t-read-only/pyvkt/component.py", line 578
    with open("avatar.png") as req:
            ^
SyntaxError: invalid syntax

---

ОС:FreeBSD6.3

Original issue reported on code.google.com by Vetal....@gmail.com on 29 Nov 2010 at 9:59

GoogleCodeExporter commented 8 years ago
добавил в каждый файл в котором 
присутствует "with open()" в начале всех вызовов 
строку
"from __future__ import with_statement" 
...теперь: 
---
#./main.py
Traceback (most recent call last):
  File "./main.py", line 4, in <module>
    import pyvkt.component
  File "~/temp/pyvk-t-read-only/pyvkt/component.py", line 30, in <module>
    from pyvkt.user import user,UnregisteredError
  File "~/temp/pyvk-t-read-only/pyvkt/user.py", line 39, in <module>
    class user (object):
  File "~/temp/pyvk-t-read-only/pyvkt/user.py", line 93, in user
    @state.setter
AttributeError: 'property' object has no attribute 'setter'
---
Python 2.5.5

Original comment by Vetal....@gmail.com on 30 Nov 2010 at 9:10

GoogleCodeExporter commented 8 years ago
совместимость с 2.5 сломана в последней 
версии, если поборете - выложите патч, я 
может позже тоже посмотрю сам.

Original comment by tishka17 on 30 Nov 2010 at 9:21

GoogleCodeExporter commented 8 years ago
добавил в "pyvkt/user.py" после вызовов
---
import __builtin__
# For Python 2.5-, this will enable the simliar property mechanism as in
# Python 2.6+/3.0+. The code is based on
# http://bruynooghe.blogspot.com/2008/04/xsetter-syntax-in-python-25.html
if sys.version_info[:2] <= (2, 5):
    # If you need to acces original built-in propery(), uncomment the next line
    # __builtin__._property = property
    class property(property):
        def __init__(self, fget, *args, **kwargs):
            self.__doc__ = fget.__doc__
            super(property, self).__init__(fget, *args, **kwargs)

        def setter(self, fset):
            cls_ns = sys._getframe(1).f_locals
            for k, v in cls_ns.iteritems():
                if v == self:
                    propname = k
                    break
            cls_ns[propname] = property(self.fget, fset,
                            self.fdel, self.__doc__)
            return cls_ns[propname]
        def deleter(self, fdel):
            cls_ns = sys._getframe(1).f_locals
            for k, v in cls_ns.iteritems():
                if v == self:
                    propname = k
                    break
            cls_ns[propname] = property(self.fget, self.fset,
                                  fdel, self.__doc__)
            return cls_ns[propname]
    __builtin__.property = property

---
взял тут 
http_://blog.yjl.im/2009/02/propery-setter-and-deleter-in-python-25.html
---
есть старт!

Original comment by Vetal....@gmail.com on 30 Nov 2010 at 11:00