@@ -113,7 +113,7 @@ mod _io {
113113 BufferDescriptor , BufferMethods , BufferResizeGuard , PyBuffer , PyIterReturn , VecBuffer ,
114114 } ,
115115 recursion:: ReprGuard ,
116- types:: { Constructor , Destructor , Initializer , IterNext , Iterable } ,
116+ types:: { Constructor , DefaultConstructor , Destructor , Initializer , IterNext , Iterable } ,
117117 vm:: VirtualMachine ,
118118 AsObject , Context , PyObject , PyObjectRef , PyPayload , PyRef , PyResult ,
119119 TryFromBorrowedObject , TryFromObject ,
@@ -1670,13 +1670,13 @@ mod _io {
16701670 }
16711671 }
16721672
1673- #[ pyimpl( with ( BufferedMixin , BufferedReadable ) , flags ( BASETYPE , HAS_DICT ) ) ]
1674- impl BufferedReader {
1675- # [ pyslot ]
1676- fn slot_new ( cls : PyTypeRef , _args : FuncArgs , vm : & VirtualMachine ) -> PyResult {
1677- Self :: default ( ) . into_ref_with_type ( vm , cls ) . map ( Into :: into )
1678- }
1679- }
1673+ #[ pyimpl(
1674+ with ( DefaultConstructor , BufferedMixin , BufferedReadable ) ,
1675+ flags ( BASETYPE , HAS_DICT )
1676+ ) ]
1677+ impl BufferedReader { }
1678+
1679+ impl DefaultConstructor for BufferedReader { }
16801680
16811681 #[ pyimpl]
16821682 trait BufferedWritable : PyPayload {
@@ -1719,13 +1719,13 @@ mod _io {
17191719 }
17201720 }
17211721
1722- #[ pyimpl( with ( BufferedMixin , BufferedWritable ) , flags ( BASETYPE , HAS_DICT ) ) ]
1723- impl BufferedWriter {
1724- # [ pyslot ]
1725- fn slot_new ( cls : PyTypeRef , _args : FuncArgs , vm : & VirtualMachine ) -> PyResult {
1726- Self :: default ( ) . into_ref_with_type ( vm , cls ) . map ( Into :: into )
1727- }
1728- }
1722+ #[ pyimpl(
1723+ with ( DefaultConstructor , BufferedMixin , BufferedWritable ) ,
1724+ flags ( BASETYPE , HAS_DICT )
1725+ ) ]
1726+ impl BufferedWriter { }
1727+
1728+ impl DefaultConstructor for BufferedWriter { }
17291729
17301730 #[ pyattr]
17311731 #[ pyclass( name = "BufferedRandom" , base = "_BufferedIOBase" ) ]
@@ -1755,15 +1755,12 @@ mod _io {
17551755 }
17561756
17571757 #[ pyimpl(
1758- with( BufferedMixin , BufferedReadable , BufferedWritable ) ,
1758+ with( DefaultConstructor , BufferedMixin , BufferedReadable , BufferedWritable ) ,
17591759 flags( BASETYPE , HAS_DICT )
17601760 ) ]
1761- impl BufferedRandom {
1762- #[ pyslot]
1763- fn slot_new ( cls : PyTypeRef , _args : FuncArgs , vm : & VirtualMachine ) -> PyResult {
1764- Self :: default ( ) . into_ref_with_type ( vm, cls) . map ( Into :: into)
1765- }
1766- }
1761+ impl BufferedRandom { }
1762+
1763+ impl DefaultConstructor for BufferedRandom { }
17671764
17681765 #[ pyattr]
17691766 #[ pyclass( name = "BufferedRWPair" , base = "_BufferedIOBase" ) ]
@@ -1785,13 +1782,7 @@ mod _io {
17851782 }
17861783 }
17871784
1788- impl Constructor for BufferedRWPair {
1789- type Args = FuncArgs ;
1790-
1791- fn py_new ( cls : PyTypeRef , _args : Self :: Args , vm : & VirtualMachine ) -> PyResult {
1792- Self :: default ( ) . into_ref_with_type ( vm, cls) . map ( Into :: into)
1793- }
1794- }
1785+ impl DefaultConstructor for BufferedRWPair { }
17951786
17961787 impl Initializer for BufferedRWPair {
17971788 type Args = ( PyObjectRef , PyObjectRef , BufferSize ) ;
@@ -1808,7 +1799,7 @@ mod _io {
18081799 }
18091800
18101801 #[ pyimpl(
1811- with( Constructor , Initializer , BufferedReadable , BufferedWritable ) ,
1802+ with( DefaultConstructor , Initializer , BufferedReadable , BufferedWritable ) ,
18121803 flags( BASETYPE , HAS_DICT )
18131804 ) ]
18141805 impl BufferedRWPair {
@@ -2188,13 +2179,7 @@ mod _io {
21882179 data : PyThreadMutex < Option < TextIOData > > ,
21892180 }
21902181
2191- impl Constructor for TextIOWrapper {
2192- type Args = FuncArgs ;
2193-
2194- fn py_new ( cls : PyTypeRef , _args : Self :: Args , vm : & VirtualMachine ) -> PyResult {
2195- Self :: default ( ) . into_ref_with_type ( vm, cls) . map ( Into :: into)
2196- }
2197- }
2182+ impl DefaultConstructor for TextIOWrapper { }
21982183
21992184 impl Initializer for TextIOWrapper {
22002185 type Args = TextIOWrapperArgs ;
@@ -2289,7 +2274,7 @@ mod _io {
22892274 }
22902275 }
22912276
2292- #[ pyimpl( with( Constructor , Initializer ) , flags( BASETYPE ) ) ]
2277+ #[ pyimpl( with( DefaultConstructor , Initializer ) , flags( BASETYPE ) ) ]
22932278 impl TextIOWrapper {
22942279 #[ pymethod]
22952280 fn seekable ( & self , vm : & VirtualMachine ) -> PyResult {
@@ -3709,12 +3694,12 @@ mod _io {
37093694mod fileio {
37103695 use super :: { Offset , _io:: * } ;
37113696 use crate :: {
3712- builtins:: { PyStr , PyStrRef , PyTypeRef } ,
3697+ builtins:: { PyStr , PyStrRef } ,
37133698 convert:: ToPyException ,
37143699 crt_fd:: Fd ,
3715- function:: { ArgBytesLike , ArgMemoryBuffer , FuncArgs , OptionalArg , OptionalOption } ,
3700+ function:: { ArgBytesLike , ArgMemoryBuffer , OptionalArg , OptionalOption } ,
37163701 stdlib:: os,
3717- types:: { Constructor , Initializer } ,
3702+ types:: { DefaultConstructor , Initializer } ,
37183703 AsObject , PyObjectRef , PyPayload , PyRef , PyResult , TryFromObject , VirtualMachine ,
37193704 } ;
37203705 use crossbeam_utils:: atomic:: AtomicCell ;
@@ -3841,21 +3826,19 @@ mod fileio {
38413826 opener : Option < PyObjectRef > ,
38423827 }
38433828
3844- impl Constructor for FileIO {
3845- type Args = FuncArgs ;
3846-
3847- fn py_new ( cls : PyTypeRef , _args : Self :: Args , vm : & VirtualMachine ) -> PyResult {
3848- FileIO {
3829+ impl Default for FileIO {
3830+ fn default ( ) -> Self {
3831+ Self {
38493832 fd : AtomicCell :: new ( -1 ) ,
38503833 closefd : AtomicCell :: new ( false ) ,
38513834 mode : AtomicCell :: new ( Mode :: empty ( ) ) ,
38523835 seekable : AtomicCell :: new ( None ) ,
38533836 }
3854- . into_ref_with_type ( vm, cls)
3855- . map ( Into :: into)
38563837 }
38573838 }
38583839
3840+ impl DefaultConstructor for FileIO { }
3841+
38593842 impl Initializer for FileIO {
38603843 type Args = FileIOArgs ;
38613844
@@ -3901,7 +3884,7 @@ mod fileio {
39013884 }
39023885 }
39033886
3904- #[ pyimpl( with( Constructor , Initializer ) , flags( BASETYPE , HAS_DICT ) ) ]
3887+ #[ pyimpl( with( DefaultConstructor , Initializer ) , flags( BASETYPE , HAS_DICT ) ) ]
39053888 impl FileIO {
39063889 #[ pyproperty]
39073890 fn closed ( & self ) -> bool {
0 commit comments