Repository: mesonbuild/meson

Issue:
TypeError: __init__() missing 1 required positional argument: 'colno'
```python
The Meson build system
Version: 0.40.0.dev1
Source dir: /builddir/build/BUILD/meson-0.39.1/test cases/python3/2 extmodule
Build dir: /builddir/build/BUILD/meson-0.39.1/b o2bri460
Build type: native build
Project name: Python extension module
Native c compiler: cc (gcc 7.0.1)
Build machine cpu family: x86_64
Build machine cpu: x86_64
Native dependency python3 found: YES 3.6
Build targets in project: 1
[1/2] cc  '-Iext/tachyon@sha' '-Iext' '-I../test cases/python3/2 extmodule/ext' '-I/usr/include/python3.6m' '-fdiagnostics-color=always' '-pipe' '-D_FILE_OFFSET_BITS=64' '-Wall' '-Winvalid-pch' '-O3' '-fPIC' '-MMD' '-MQ' 'ext/tachyon@sha/tachyon_module.c.o' '-MF' 'ext/tachyon@sha/tachyon_module.c.o.d' -o 'ext/tachyon@sha/tachyon_module.c.o' -c '../test cases/python3/2 extmodule/ext/tachyon_module.c'
[2/2] cc  -o ext/tachyon.so 'ext/tachyon@sha/tachyon_module.c.o' '-Wl,--as-needed' '-Wl,-O1' '-shared' '-fPIC' '-Wl,-soname,tachyon.so' '-lpython3.6m' '-Wl,-rpath,/builddir/build/BUILD/meson-0.39.1/b o2bri460/ext'  
1/1 extmod                                  OK       0.04 s
OK:         1
FAIL:       0
SKIP:       0
TIMEOUT:    0
Full log written to /builddir/build/BUILD/meson-0.39.1/b o2bri460/meson-logs/testlog.txt
No tests defined.
[0/1] '/usr/bin/python3' '/builddir/build/BUILD/meson-0.39.1/meson.py' '--internal' 'install' '/builddir/build/BUILD/meson-0.39.1/b o2bri460/meson-private/install.dat'
[1/1] 'ninja-build' '-t' 'clean'
Cleaning... 2 files.
Traceback (most recent call last):
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/mesonmain.py", line 298, in run
    app.generate()
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/mesonmain.py", line 172, in generate
    intr = interpreter.Interpreter(b, g)
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/interpreter.py", line 1241, in __init__
    self.load_root_meson_file()
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/interpreterbase.py", line 101, in load_root_meson_file
    self.ast = mparser.Parser(code, self.subdir).parse()
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/mparser.py", line 440, in parse
    block = self.codeblock()
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/mparser.py", line 669, in codeblock
    curline = self.line()
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/mparser.py", line 663, in line
    return self.statement()
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/mparser.py", line 445, in statement
    return self.e1()
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/mparser.py", line 452, in e1
    raise ParseException('Plusassignment target must be an id.', left.lineno, left.colno)
TypeError: __init__() missing 1 required positional argument: 'colno'
Traceback (most recent call last):
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/mesonmain.py", line 298, in run
    app.generate()
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/mesonmain.py", line 172, in generate
    intr = interpreter.Interpreter(b, g)
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/interpreter.py", line 1241, in __init__
    self.load_root_meson_file()
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/interpreterbase.py", line 101, in load_root_meson_file
    self.ast = mparser.Parser(code, self.subdir).parse()
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/mparser.py", line 440, in parse
    block = self.codeblock()
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/mparser.py", line 669, in codeblock
    curline = self.line()
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/mparser.py", line 663, in line
    return self.statement()
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/mparser.py", line 445, in statement
    return self.e1()
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/mparser.py", line 455, in e1
    value = self.e1()
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/mparser.py", line 465, in e1
    trueblock = self.e1()
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/mparser.py", line 448, in e1
    left = self.e2()
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/mparser.py", line 473, in e2
    left = self.e3()
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/mparser.py", line 479, in e3
    left = self.e4()
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/mparser.py", line 485, in e4
    left = self.e5()
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/mparser.py", line 492, in e5
    return self.e5add()
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/mparser.py", line 495, in e5add
    left = self.e5sub()
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/mparser.py", line 501, in e5sub
    left = self.e5mod()
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/mparser.py", line 507, in e5mod
    left = self.e5mul()
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/mparser.py", line 513, in e5mul
    left = self.e5div()
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/mparser.py", line 519, in e5div
    left = self.e6()
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/mparser.py", line 529, in e6
    return self.e7()
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/mparser.py", line 532, in e7
    left = self.e8()
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/mparser.py", line 555, in e8
    e = self.statement()
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/mparser.py", line 445, in statement
    return self.e1()
  File "/builddir/build/BUILD/meson-0.39.1/mesonbuild/mparser.py", line 463, in e1
    left.lineno, left.colno)
TypeError: __init__() missing 1 required positional argument: 'colno'
Succeeded test: test cases/python3/3 cython
```


Discussion:

Resolving patch:
diff --git a/mesonbuild/mparser.py b/mesonbuild/mparser.py
--- a/mesonbuild/mparser.py
+++ b/mesonbuild/mparser.py
@@ -420,6 +420,9 @@ def getsym(self):
         except StopIteration:
             self.current = Token('eof', '', self.current.line_start, self.current.lineno, self.current.colno + self.current.bytespan[1] - self.current.bytespan[0], (0, 0), None)
 
+    def getline(self):
+        return self.lexer.getline(self.current.line_start)
+
     def accept(self, s):
         if self.current.tid == s:
             self.getsym()
@@ -429,12 +432,12 @@ def accept(self, s):
     def expect(self, s):
         if self.accept(s):
             return True
-        raise ParseException('Expecting %s got %s.' % (s, self.current.tid), self.lexer.getline(self.current.line_start), self.current.lineno, self.current.colno)
+        raise ParseException('Expecting %s got %s.' % (s, self.current.tid), self.getline(), self.current.lineno, self.current.colno)
 
     def block_expect(self, s, block_start):
         if self.accept(s):
             return True
-        raise BlockParseException('Expecting %s got %s.' % (s, self.current.tid), self.lexer.getline(self.current.line_start), self.current.lineno, self.current.colno, self.lexer.getline(block_start.line_start), block_start.lineno, block_start.colno)
+        raise BlockParseException('Expecting %s got %s.' % (s, self.current.tid), self.getline(), self.current.lineno, self.current.colno, self.lexer.getline(block_start.line_start), block_start.lineno, block_start.colno)
 
     def parse(self):
         block = self.codeblock()
@@ -449,18 +452,18 @@ def e1(self):
         if self.accept('plusassign'):
             value = self.e1()
             if not isinstance(left, IdNode):
-                raise ParseException('Plusassignment target must be an id.', left.lineno, left.colno)
+                raise ParseException('Plusassignment target must be an id.', self.getline(), left.lineno, left.colno)
             return PlusAssignmentNode(left.lineno, left.colno, left.value, value)
         elif self.accept('assign'):
             value = self.e1()
             if not isinstance(left, IdNode):
                 raise ParseException('Assignment target must be an id.',
-                                     left.lineno, left.colno)
+                                     self.getline(), left.lineno, left.colno)
             return AssignmentNode(left.lineno, left.colno, left.value, value)
         elif self.accept('questionmark'):
             if self.in_ternary:
                 raise ParseException('Nested ternary operators are not allowed.',
-                                     left.lineno, left.colno)
+                                     self.getline(), left.lineno, left.colno)
             self.in_ternary = True
             trueblock = self.e1()
             self.expect('colon')
@@ -536,7 +539,7 @@ def e7(self):
             self.block_expect('rparen', block_start)
             if not isinstance(left, IdNode):
                 raise ParseException('Function call must be applied to plain id',
-                                     left.lineno, left.colno)
+                                     self.getline(), left.lineno, left.colno)
             left = FunctionNode(left.subdir, left.lineno, left.colno, left.value, args)
         go_again = True
         while go_again:
@@ -588,7 +591,7 @@ def args(self):
             elif self.accept('colon'):
                 if not isinstance(s, IdNode):
                     raise ParseException('Keyword argument must be a plain identifier.',
-                                         s.lineno, s.colno)
+                                         self.getline(), s.lineno, s.colno)
                 a.set_kwarg(s.value, self.statement())
                 potential = self.current
                 if not self.accept('comma'):
@@ -604,7 +607,7 @@ def method_call(self, source_object):
         methodname = self.e9()
         if not(isinstance(methodname, IdNode)):
             raise ParseException('Method name must be plain id',
-                                 self.current.lineno, self.current.colno)
+                                 self.getline(), self.current.lineno, self.current.colno)
         self.expect('lparen')
         args = self.args()
         self.expect('rparen')


Test patch: