@@ -63,10 +63,10 @@ class ulong(long):
6363 An unsigned 64 bit integer in the range :math:`0` to :math:`2^{64} - 1` inclusive.
6464 """
6565
66- def __init__ (self , u64 : int ) -> None :
66+ def __new__ (self , u64 : int ) -> ulong :
6767 if u64 < 0 :
68- raise AssertionError ("initializing ulong with negative value" )
69- super ().__new__ (ulong , u64 )
68+ raise ValueError ("initializing ulong with negative value" )
69+ return super ().__new__ (ulong , u64 )
7070
7171 def __repr__ (self ) -> str :
7272 return "ulong(%s)" % long .__repr__ (self )
@@ -148,10 +148,10 @@ class ubyte(int):
148148 An 8 bit unsigned integer in the range :math:`0` to :math:`2^8 - 1` inclusive.
149149 """
150150
151- def __init__ (self , i : int ) -> None :
151+ def __new__ (self , i : int ) -> ubyte :
152152 if i < 0 :
153- raise AssertionError ("initializing ubyte with negative value" )
154- super ().__new__ (ubyte , i )
153+ raise ValueError ("initializing ubyte with negative value" )
154+ return super ().__new__ (ubyte , i )
155155
156156 def __repr__ (self ) -> str :
157157 return "ubyte(%s)" % int .__repr__ (self )
@@ -164,10 +164,10 @@ class ushort(int):
164164 A 16 bit unsigned integer in the range :math:`0` to :math:`2^{16} - 1` inclusive.
165165 """
166166
167- def __init__ (self , i : int ) -> None :
167+ def __new__ (self , i : int ) -> ushort :
168168 if i < 0 :
169- raise AssertionError ("initializing ushort with negative value" )
170- super ().__new__ (ushort , i )
169+ raise ValueError ("initializing ushort with negative value" )
170+ return super ().__new__ (ushort , i )
171171
172172 def __repr__ (self ) -> str :
173173 return "ushort(%s)" % int .__repr__ (self )
@@ -180,10 +180,10 @@ class uint(long):
180180 A 32 bit unsigned integer in the range :math:`0` to :math:`2^{32} - 1` inclusive.
181181 """
182182
183- def __init__ (self , u32 : int ) -> None :
183+ def __new__ (self , u32 : int ) -> uint :
184184 if u32 < 0 :
185- raise AssertionError ("initializing uint with negative value" )
186- super ().__new__ (uint , u32 )
185+ raise ValueError ("initializing uint with negative value" )
186+ return super ().__new__ (uint , u32 )
187187
188188 def __repr__ (self ) -> str :
189189 return "uint(%s)" % long .__repr__ (self )
0 commit comments