Opened 6 years ago

Closed 6 years ago

#3662 closed defect (fixed)

pygrass open vector fails in python3

Reported by: martinl Owned by: grass-dev@…
Priority: normal Milestone: 7.8.0
Component: PyGRASS Version: svn-trunk
Keywords: python3 Cc:
CPU: Unspecified Platform: Unspecified

Description

Opening vector map using PyGRASS fails in Python3:

>>> from grass.pygrass.vector import Vector
>>> s = Vector('streams')
>>> s.open('r')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/src/grass7_trunk_py3/dist.x86_64-pc-linux-gnu/etc/python/grass/pygrass/vector/abstract.py", line 380, in open
    self.table = self.dblinks.by_layer(layer).table()
  File "/opt/src/grass7_trunk_py3/dist.x86_64-pc-linux-gnu/etc/python/grass/pygrass/vector/table.py", line 801, in table
    return Table(self.table_name, self.connection(), self.key)
  File "/opt/src/grass7_trunk_py3/dist.x86_64-pc-linux-gnu/etc/python/grass/pygrass/vector/table.py", line 764, in connection
    dbpath = get_path(self.database, self.table_name)
  File "/opt/src/grass7_trunk_py3/dist.x86_64-pc-linux-gnu/etc/python/grass/pygrass/vector/table.py", line 67, in get_path
    if "$" not in path:
  File "/opt/src/grass7_trunk_py3/dist.x86_64-pc-linux-gnu/etc/python/grass/lib/ctypes_preamble.py", line 78, in __contains__
    return char in self.data
TypeError: a bytes-like object is required, not 'str'

Change History (3)

comment:1 by martinl, 6 years ago

Version: unspecifiedsvn-trunk

comment:2 by annakrat, 6 years ago

In 73435:

pygrass: fix for Python 3, see #3662

comment:3 by martinl, 6 years ago

Resolution: fixed
Status: newclosed
>>> s.is_open()
True

works for me. Thanks for quick fix!

Note: See TracTickets for help on using tickets.