Skip to content

Segmentation fault on unrelated Python exceptions #87

@ltog

Description

@ltog

I'd like to use pyosmium using Python 3.6.2. When running the following example code (based on https://github.com/osmcode/pyosmium/blob/master/examples/osm_file_stats.py ) using Python 3, I get a Segmentation fault (core dumped) message (caused by the last line of code) with no additional info. However, running the same code using Python 2.7.15+, gives me a proper error message.

My question is not about this specific example, but about the combination of python3 and pyosmium in general: How would I debug such errors (and why aren't any proper error messages displayed)?

import osmium as o
import sys

class FileStatsHandler(o.SimpleHandler):

    def __init__(self):
        super(FileStatsHandler, self).__init__()
        self.nodes = 0

    def node(self, n):
        self.nodes += 1

if __name__ == '__main__':
    if len(sys.argv) != 2:
        print("Usage: python osm_file_stats.py <osmfile>")
        sys.exit(-1)

    h = FileStatsHandler()

    h.apply_file(sys.argv[1])

    print("Nodes: %d" % h.nodes)
    print("Nodes: " + h.nodes) # XXX: h.nodes should be str(h.nodes)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions