[Numpy-svn] [numpy/numpy] fc4ade: ENH: Fix SyntaxError when matrix() is called with ...

GitHub noreply at github.com
Wed May 29 09:57:04 EDT 2013


  Branch: refs/heads/master
  Home:   https://github.com/numpy/numpy
  Commit: fc4ade26312bd66474834aa0bee42265e7e15353
      https://github.com/numpy/numpy/commit/fc4ade26312bd66474834aa0bee42265e7e15353
  Author: Leon Weber <leon at leonweber.de>
  Date:   2013-05-29 (Wed, 29 May 2013)

  Changed paths:
    M numpy/matrixlib/defmatrix.py
    M numpy/matrixlib/tests/test_defmatrix.py

  Log Message:
  -----------
  ENH: Fix SyntaxError when matrix() is called with invalid string

The numpy.matrix constructor uses eval(str.translate(table)) to convert
input strings to numeric matrix contents. str.translate(table) will
return empty string if str consists only of invalid characters, causing
SyntaxError in eval(). This is confusing, as one would expect an
exception like TypeError when trying to construct a matrix from invalid
input.

This fix makes sure eval() is only called if str is not empty and
TypeError is raised otherwise.


  Commit: 1f11f22ad71da9cb95b541be01fbfb4eed6d3d5b
      https://github.com/numpy/numpy/commit/1f11f22ad71da9cb95b541be01fbfb4eed6d3d5b
  Author: Charles Harris <charlesr.harris at gmail.com>
  Date:   2013-05-29 (Wed, 29 May 2013)

  Changed paths:
    M numpy/matrixlib/defmatrix.py
    M numpy/matrixlib/tests/test_defmatrix.py

  Log Message:
  -----------
  Merge pull request #3358 from leonnnn/matrix-typeerror

ENH: Fix SyntaxError when matrix() is called with invalid string


Compare: https://github.com/numpy/numpy/compare/aa1cfce920ec...1f11f22ad71d


More information about the Numpy-svn mailing list