1- use crate :: exceptions:: PyBaseExceptionRef ;
1+ use crate :: exceptions:: { IntoPyException , PyBaseExceptionRef } ;
22use crate :: function:: PyFuncArgs ;
33use crate :: obj:: { objstr, objtype} ;
44use crate :: pyobject:: { ItemProtocol , PyObjectRef , PyResult , TypeProtocol } ;
@@ -563,9 +563,8 @@ pub(crate) enum FormatParseError {
563563 InvalidCharacterAfterRightBracket ,
564564}
565565
566- impl FormatParseError {
567- // TODO: IntoPyException
568- pub fn into_pyobject ( self , vm : & VirtualMachine ) -> PyBaseExceptionRef {
566+ impl IntoPyException for FormatParseError {
567+ fn into_pyexception ( self , vm : & VirtualMachine ) -> PyBaseExceptionRef {
569568 match self {
570569 FormatParseError :: UnmatchedBracket => {
571570 vm. new_value_error ( "expected '}' before end of string" . to_owned ( ) )
@@ -812,8 +811,8 @@ impl FormatString {
812811 preconversion_spec,
813812 format_spec,
814813 } => {
815- let FieldName { field_type, parts } =
816- FieldName :: parse ( field_name . as_str ( ) ) . map_err ( |e| e. into_pyobject ( vm) ) ?;
814+ let FieldName { field_type, parts } = FieldName :: parse ( field_name . as_str ( ) )
815+ . map_err ( |e| e. into_pyexception ( vm) ) ?;
817816
818817 let mut argument = field_func ( & field_type) ?;
819818
@@ -832,7 +831,7 @@ impl FormatString {
832831 }
833832
834833 let nested_format =
835- FormatString :: from_str ( & format_spec) . map_err ( |e| e. into_pyobject ( vm) ) ?;
834+ FormatString :: from_str ( & format_spec) . map_err ( |e| e. into_pyexception ( vm) ) ?;
836835 let format_spec = nested_format. format_internal ( vm, field_func) ?;
837836
838837 let value =
0 commit comments