classification
Title: Typo/trivial mistake in warnings.py (may be related to 2.x to 3.x conversion)
Type: compile error Stage:
Components: Argument Clinic Versions: Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: larry, serhiy.storchaka, tashrifbillah, vstinner
Priority: normal Keywords:

Created on 2018-11-06 15:07 by tashrifbillah, last changed 2018-11-06 20:46 by vstinner.

Pull Requests
URL Status Linked Edit
PR 10343 open tashrifbillah, 2018-11-06 15:07
Messages (3)
msg329363 - (view) Author: Tashrif Billah (tashrifbillah) * Date: 2018-11-06 15:07
```
2018-11-06 09:51:27,314 /home/tb571/Downloads/pnlpipe/pnlscripts/wmql.py DEBUG  Running ['/home/tb571/Downloads/pnlpipe/soft_dir/tract_querier-c57d670/scripts/tract_math', '/home/tb571/Downloads/pnlpipe/_data/003_GNX_007/Ukf-003_GNX_007-761f2a551e.vtk', 'tract_remove_short_tracts', '2', '/tmp/tmpq2z9fmfc/ukfpruned.vtk']
Traceback (most recent call last):
  File "/home/tb571/Downloads/pnlpipe/soft_dir/tract_querier-c57d670/scripts/tract_math", line 115, in main
    tractography, *args.operation_parameters)
  File "/home/tb571/Downloads/pnlpipe/soft_dir/tract_querier-c57d670/tract_querier/tract_math/decorator.py", line 141, in wrapper
    process_output(out, file_output=file_output)
  File "/home/tb571/Downloads/pnlpipe/soft_dir/tract_querier-c57d670/tract_querier/tract_math/decorator.py", line 176, in process_output
    tractography_to_file(file_output, output)
  File "/home/tb571/Downloads/pnlpipe/soft_dir/tract_querier-c57d670/tract_querier/tractography/__init__.py", line 85, in tractography_to_file
    return tractography_to_vtk_file(filename, tractography, **kwargs)
  File "/home/tb571/Downloads/pnlpipe/soft_dir/tract_querier-c57d670/tract_querier/tractography/vtkInterface.py", line 29, in tractography_to_vtk_file
    tractography.tracts_data()
  File "/home/tb571/Downloads/pnlpipe/soft_dir/tract_querier-c57d670/tract_querier/tractography/vtkInterface.py", line 324, in write_vtkPolyData
    poly_data = tracts_to_vtkPolyData(tracts, tracts_data=tracts_data)
  File "/home/tb571/Downloads/pnlpipe/soft_dir/tract_querier-c57d670/tract_querier/tractography/vtkInterface.py", line 267, in tracts_to_vtkPolyData
    vtk_ids = ns.numpy_to_vtkIdTypeArray(ids, deep=True)
  File "/home/tb571/miniconda3/envs/pnlpipe3/lib/python3.6/site-packages/vtk/util/numpy_support.py", line 198, in numpy_to_vtkIdTypeArray
    return numpy_to_vtk(num_array, deep, vtk.VTK_ID_TYPE)
  File "/home/tb571/miniconda3/envs/pnlpipe3/lib/python3.6/site-packages/vtk/util/numpy_support.py", line 137, in numpy_to_vtk
    assert not numpy.issubdtype(z.dtype, complex), \
  File "/home/tb571/miniconda3/envs/pnlpipe3/lib/python3.6/site-packages/numpy/core/numerictypes.py", line 743, in issubdtype
    FutureWarning, stacklevel=2
  File "/home/tb571/miniconda3/envs/pnlpipe3/lib/python3.6/warnings.py", line 101, in _showwarnmsg
    _showwarnmsg_impl(msg)
  File "/home/tb571/miniconda3/envs/pnlpipe3/lib/python3.6/warnings.py", line 28, in _showwarnmsg_impl
    text = _formatwarnmsg(msg)
  File "/home/tb571/miniconda3/envs/pnlpipe3/lib/python3.6/warnings.py", line 116, in _formatwarnmsg
    msg.filename, msg.lineno, line= msg.line)
TypeError: custom_formatwarning() got an unexpected keyword argument 'line'
```
msg329364 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-11-06 15:22
This may be a consequence of issue26568.
msg329385 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-11-06 20:46
> Typo/trivial mistake in warnings.py (may be related to 2.x to 3.x conversion)

It's not a typo: it's that my change now requires the last argument of formatwarning() to be a keyword argument called 'line'.

The error comes from numpy.

But I'm fine to now require that the last formatwarning() argument is called 'line' and pass its value as an positional argument, not as a keyword argument.

In that case, I would like to see an unit test to check that replacing warnings.formatwarning() with a new function and the last parameter of this function is not called 'line' still works.
History
Date User Action Args
2018-11-06 20:46:40vstinnersetmessages: + msg329385
2018-11-06 15:22:23serhiy.storchakasetnosy: + vstinner, serhiy.storchaka
messages: + msg329364
2018-11-06 15:07:10tashrifbillahcreate