On Friday, August 9, 2019 at 1:47:52 PM UTC-7, Константин Комков wrote:
>
> *Val K*, yes, I have database which contain images. I tried use blob ↓.
> I don't know why but if I do like that I have error:
> table.py
> db.define_table(
>     'recipes',
>     Field('NAME',length=512),
>     Field('IMAGE','*blob*'),
>     migrate=False
> )
> and query in controller:
> db().select(db.recipes.IMAGE).first()
> Версия
> web2py™ Version 2.18.5-stable+timestamp.2019.04.08.04.22.03
> Python Python 3.7.3: C:\Program Files (x86)\Python37-32\python.exe 
> (prefix: C:\Program Files (x86)\Python37-32)Traceback
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
> 17.
> 18.
> 19.
> 20.
> 21.
> 22.
> 23.
> 24.
> 25.
> 26.
> 27.
> 28.
> 29.
> 30.
> 31.
> 32.
> 33.
> 34.
>
> Traceback (most recent call last):
>   File "C:\web2py\gluon\restricted.py", line 219, in restricted
>     exec(ccode, environment)
>   File "C:\web2py\applications\test\controllers/default.py", line 61, in 
> <module>
>   File "C:\web2py\gluon\globals.py", line 421, in <lambda>
>     self._caller = lambda f: f()
>   File "C:\web2py\applications\test\controllers/default.py", line 9, in index
>     db().select(db.recipes.IMAGE).first()
>   File "C:\web2py\gluon\packages\dal\pydal\objects.py", line 2395, in select
>     return adapter.select(self.query, fields, attributes)
>   File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 763, in 
> select
>     return self._select_aux(sql, fields, attributes, colnames)
>   File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 742, in 
> _select_aux
>     return processor(rows, fields, colnames, cacheable=cacheable)
>   File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 306, in 
> parse
>     for row in rows
>   File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 303, in 
> <listcomp>
>     self._parse(
>   File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 232, in 
> _parse
>     value = self.parse_value(value, fit, ft, blob_decode)
>   File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 199, in 
> parse_value
>     return self.parser.parse(value, field_itype, field_type)
>   File "C:\web2py\gluon\packages\dal\pydal\parsers\__init__.py", line 100, in 
> parse
>     return self.registered[field_itype](value, field_type)
>   File "C:\web2py\gluon\packages\dal\pydal\parsers\__init__.py", line 75, in 
> __call__
>     return self.call(value, field_type)
>   File "C:\web2py\gluon\packages\dal\pydal\parsers\__init__.py", line 72, in 
> _call
>     return self.f(self.parser, value)
>   File "C:\web2py\gluon\packages\dal\pydal\parsers\base.py", line 37, in _blob
>     decoded = b64decode(to_bytes(value))
>   File "C:\web2py\gluon\packages\dal\pydal\_compat.py", line 131, in to_bytes
>     raise TypeError('Expected bytes')
> TypeError: Expected bytes
>
> Error snapshot [image: help] 
> <http://127.0.0.1:8000/admin/default/ticket/test/127.0.0.1.2019-08-09.23-35-41.70898352-368b-4941-a3b8-c3eb55b113f9#>
>
> TypeError(Expected bytes)
>
> inspect attributes
> Frames
>    
>    - 
>    
>    *File C:\web2py\gluon\restricted.py in restricted at line 219* код 
>    аргументы переменные
>    - 
>    
>    *File C:\web2py\applications\test\controllers\default.py in <module> 
>    at line 61* код аргументы переменные
>    - 
>    
>    *File C:\web2py\gluon\globals.py in <lambda> at line 421* код аргументы
>     переменные
>    - 
>    
>    *File C:\web2py\applications\test\controllers\default.py in index at 
>    line 9* код аргументы переменные
>    - 
>    
>    *File C:\web2py\gluon\packages\dal\pydal\objects.py in select at line 
>    2395* код аргументы переменные
>    Code listing
>    
>    2390.
>    2391.
>    2392.
>    2393.
>    2394.
>    2395.
>    2396.
>    2397.
>    2398.
>    2399.
>    
>                                        attributes.get('join', None),
>                                        attributes.get('left', None),
>                                        attributes.get('orderby', None),
>                                        attributes.get('groupby', None))
>            fields = adapter.expand_all(fields, tablenames)
>            return adapter.select(self.query, fields, attributes)
>    
>        def iterselect(self, *fields, **attributes):
>            adapter = self.db._adapter
>            tablenames = adapter.tables(self.query,
>    
>    - 
>    
>    *File C:\web2py\gluon\packages\dal\pydal\adapters\base.py in select at 
>    line 763* код аргументы переменные
>    - 
>    
>    *File C:\web2py\gluon\packages\dal\pydal\adapters\base.py in 
>    _select_aux at line 742* код аргументы переменные
>    - 
>    
>    *File C:\web2py\gluon\packages\dal\pydal\adapters\base.py in parse at 
>    line 306* код аргументы переменные
>    - 
>    
>    *File C:\web2py\gluon\packages\dal\pydal\adapters\base.py in 
>    <listcomp> at line 303* код аргументы переменные
>    - 
>    
>    *File C:\web2py\gluon\packages\dal\pydal\adapters\base.py in _parse at 
>    line 232* код аргументы переменные
>    - 
>    
>    *File C:\web2py\gluon\packages\dal\pydal\adapters\base.py in 
>    parse_value at line 199* код аргументы переменные
>    - 
>    
>    *File C:\web2py\gluon\packages\dal\pydal\parsers\__init__.py in parse 
>    at line 100* код аргументы переменные
>    - 
>    
>    *File C:\web2py\gluon\packages\dal\pydal\parsers\__init__.py in 
>    __call__ at line 75* код аргументы переменные
>    - 
>    
>    *File C:\web2py\gluon\packages\dal\pydal\parsers\__init__.py in _call 
>    at line 72* код аргументы переменные
>    - 
>    
>    *File C:\web2py\gluon\packages\dal\pydal\parsers\base.py in _blob at 
>    line 37* код аргументы переменные
>    - 
>    
>    *File C:\web2py\gluon\packages\dal\pydal\_compat.py in to_bytes at 
>    line 131* код аргументы переменные
>    Function argument list
>    
>    (obj=<fdb.fbcore.BlobReader object>, charset='utf-8', errors='strict')
>    Code listing
>    
>    126.
>    127.
>    128.
>    129.
>    130.
>    131.
>    132.
>    133.
>    134.
>    135.
>    
>                return None
>            if isinstance(obj, (bytes, bytearray, memoryview)):
>                return bytes(obj)
>            if isinstance(obj, str):
>                return obj.encode(charset, errors)
>            raise TypeError('Expected bytes')
>    
>        def to_native(obj, charset='utf8', errors='strict'):
>            if obj is None or isinstance(obj, str):
>                return obj
>    
>    
> Is it bug of DAL or it's normal?
>



That looks like a Python2 vs Python3 issue.    And it's happening in the 
_compat.py module, which I believe is for P3 support.

/dps
 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/d4c01087-4e64-459c-9ac1-015556927fa3%40googlegroups.com.

Reply via email to