Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typo/trivial mistake in warnings.py (may be related to 2.x to 3.x conversion) #79359

Closed
tashrifbillah mannequin opened this issue Nov 6, 2018 · 7 comments
Closed

Typo/trivial mistake in warnings.py (may be related to 2.x to 3.x conversion) #79359

tashrifbillah mannequin opened this issue Nov 6, 2018 · 7 comments
Labels
3.7 (EOL) end of life 3.8 (EOL) end of life build The build process and cross-build topic-argument-clinic

Comments

@tashrifbillah
Copy link
Mannequin

tashrifbillah mannequin commented Nov 6, 2018

BPO 35178
Nosy @vstinner, @larryhastings, @serhiy-storchaka, @miss-islington, @tirkarthi, @tashrifbillah
PRs
  • bpo-35178: Pass positional arguments to formatwarning(). #10343
  • bpo-35178: Ensure custom formatwarning function can receive line as positional argument #12033
  • [3.7] bpo-35178: Fix warnings._formatwarnmsg() (GH-12033) #12130
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-03-01.17:49:20.664>
    created_at = <Date 2018-11-06.15:07:10.524>
    labels = ['3.8', 'build', '3.7', 'expert-argument-clinic']
    title = 'Typo/trivial mistake in warnings.py (may be related to 2.x to 3.x conversion)'
    updated_at = <Date 2019-03-01.17:49:20.658>
    user = 'https://github.com/tashrifbillah'

    bugs.python.org fields:

    activity = <Date 2019-03-01.17:49:20.658>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-03-01.17:49:20.664>
    closer = 'vstinner'
    components = ['Argument Clinic']
    creation = <Date 2018-11-06.15:07:10.524>
    creator = 'tashrifbillah'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 35178
    keywords = ['patch']
    message_count = 7.0
    messages = ['329363', '329364', '329385', '336537', '336934', '336941', '336942']
    nosy_count = 6.0
    nosy_names = ['vstinner', 'larry', 'serhiy.storchaka', 'miss-islington', 'xtreak', 'tashrifbillah']
    pr_nums = ['10343', '12033', '12130']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'compile error'
    url = 'https://bugs.python.org/issue35178'
    versions = ['Python 3.7', 'Python 3.8']

    @tashrifbillah
    Copy link
    Mannequin Author

    tashrifbillah mannequin commented Nov 6, 2018

    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'
    

    @tashrifbillah tashrifbillah mannequin added topic-argument-clinic build The build process and cross-build labels Nov 6, 2018
    @serhiy-storchaka
    Copy link
    Member

    This may be a consequence of bpo-26568.

    @vstinner
    Copy link
    Member

    vstinner commented Nov 6, 2018

    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.

    @tirkarthi
    Copy link
    Member

    @tashrifbillah I will be happy to add a test on a follow up PR attributing to the original PR as per #10343 (comment)

    Thanks

    @vstinner
    Copy link
    Member

    vstinner commented Mar 1, 2019

    New changeset be7c460 by Victor Stinner (Xtreak) in branch 'master':
    bpo-35178: Fix warnings._formatwarnmsg() (GH-12033)
    be7c460

    @miss-islington
    Copy link
    Contributor

    New changeset b94874f by Miss Islington (bot) in branch '3.7':
    bpo-35178: Fix warnings._formatwarnmsg() (GH-12033)
    b94874f

    @vstinner
    Copy link
    Member

    vstinner commented Mar 1, 2019

    Thanks Tashrif Billah and Karthikeyan Singaravelan for the fix!

    Sadly, Python 3.6 now only accept security fixes, and so this bug cannot be fixed in the 3.6 branch anymore.

    The workaround is the rename the last parameter of your customer formatmsg function to 'line' ;-)

    @vstinner vstinner added 3.7 (EOL) end of life 3.8 (EOL) end of life labels Mar 1, 2019
    @vstinner vstinner closed this as completed Mar 1, 2019
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 (EOL) end of life build The build process and cross-build topic-argument-clinic
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants