Closed jelly closed 3 months ago
It seems SyntaxError gets less info on Python 3.12, compared to 3.11:
3.11.8:
> PyCall.eval('raise Exception("abcdef")')
/usr/lib/ruby/gems/3.0.0/gems/pycall-1.5.1/lib/pycall/pyobject_wrapper.rb:49:in `eval': <class 'SyntaxError'>: ('invalid syntax', ('<string>', 1, 1, 'raise Exception("abcdef")', 1, 6)) (PyCall::PyError)
from /usr/lib/ruby/gems/3.0.0/gems/pycall-1.5.1/lib/pycall/pyobject_wrapper.rb:49:in `method_missing'
from /usr/lib/ruby/gems/3.0.0/gems/pycall-1.5.1/lib/pycall.rb:41:in `eval'
from (irb):2:in `<main>'
from /usr/lib/ruby/gems/3.0.0/gems/irb-1.4.2/exe/irb:11:in `<top (required)>'
from /usr/bin/irb:25:in `load'
from /usr/bin/irb:25:in `<main>'
3.12.2:
> PyCall.eval('raise Exception("abcdef")')
/usr/lib/ruby/gems/3.0.0/gems/pycall-1.5.1/lib/pycall/pyobject_wrapper.rb:49:in `eval': <class 'SyntaxError'>: invalid syntax (<string>, line 1) (PyCall::PyError)
from /usr/lib/ruby/gems/3.0.0/gems/pycall-1.5.1/lib/pycall/pyobject_wrapper.rb:49:in `method_missing'
from /usr/lib/ruby/gems/3.0.0/gems/pycall-1.5.1/lib/pycall.rb:41:in `eval'
from (irb):2:in `<main>'
from /usr/lib/ruby/gems/3.0.0/gems/irb-1.4.2/exe/irb:11:in `<top (required)>'
from /usr/bin/irb:25:in `load'
from /usr/bin/irb:25:in `<main>'
I'm not sure what caused the change, though.
Found one interesting difference:
3.11.8:
irb(main):102:1* begin
irb(main):103:1* PyCall.eval('raise Exception("abcdef")')
irb(main):104:1* rescue => error
irb(main):105:1* error.value
irb(main):106:0> end
=> ('invalid syntax', ('<string>', 1, 1, 'raise Exception("abcdef")', 1, 6))
error.value is a tuple.
3.12.2:
irb(main):064:1* begin
irb(main):065:1* PyCall.eval('raise Exception("abcdef")')
irb(main):066:1* rescue => error
irb(main):067:1* error.value
irb(main):068:0> end
=> SyntaxError('invalid syntax', ('<string>', 1, 1, 'raise Exception("abcdef")', 1, 6))
error.value is an Object.
This leads to the changes in https://github.com/python/cpython/pull/101607/files#diff-c37c836d0535b79d87b8eb0652c59ac0c2aeb1461bcb2274bee82656cecacad4L421-R475 which makes "value" the new internal exception PyObject instead.
On Python 3.12 the following test fails:
Which seems strange as it is valid Python: