IronPython.Zlib / src / ZlibModule.cs

Diff from to

src/ZlibModule.cs

  * ***************************************************************************/
 
 using System;
-using System.Collections.Generic;
-using System.Text;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using ComponentAce.Compression.Libs.ZLib;
 using IronPython.Runtime;
+using IronPython.Runtime.Exceptions;
+using IronPython.Runtime.Operations;
 using IronPython.Runtime.Types;
-using ComponentAce.Compression.Libs.ZLib;
-using System.Runtime.InteropServices;
 
 [assembly: PythonModule("zlib", typeof(IronPython.Zlib.ZlibModule))]
 
             int err = zst.deflateInit(level);
             if(err != Z_OK)
             {
-                throw new ZStreamException();
+                throw MakeError();
             }
 
             err = zst.deflate(FlushStrategy.Z_FINISH);
             if(err != Z_STREAM_END)
             {
                 zst.deflateEnd();
-                throw new ZStreamException();
+                throw MakeError();
             }
 
             err = zst.deflateEnd();
             if(err == Z_OK)
                 return Latin1.GetString(output, 0, (int)zst.total_out);
             else
-                throw new ZStreamException();
+                throw MakeError();
         }
 
         #endregion
             int err = zst.inflateInit(wbits);
             if(err != Z_OK)
             {
-                throw new ZStreamException();
+                throw MakeError();
             }
 
             do
                     if(err == Z_BUF_ERROR && zst.avail_out > 0)
                     {
                         zst.inflateEnd();
-                        throw new ZStreamException();
+                        throw MakeError();
                     }
                     else if(err == Z_OK || (err == Z_BUF_ERROR && zst.avail_out == 0))
                     {
                     else
                     {
                         zst.inflateEnd();
-                        throw new ZStreamException();
+                        throw MakeError();
                     }
                 }
 
             err = zst.inflateEnd();
             if(err != Z_OK)
             {
-                throw new ZStreamException();
+                throw MakeError();
             }
 
             if(outputOffset + outputBuffer.Length - zst.avail_out > output.Length)
 
         #endregion
 
-        public static readonly PythonType/*!*/ ZlibErrorType = DynamicHelpers.GetPythonTypeFromType(typeof(ZStreamException));
-        public static readonly PythonType/*!*/ error = ZlibErrorType;
+        [SpecialName]
+        public static void PerformModuleReload(PythonContext context, PythonDictionary dict)
+        {
+            error = context.EnsureModuleException("zlib.error", PythonExceptions.Exception, dict, "error", "zlib");
+        }
+
+        public static PythonType error;
+        internal static Exception MakeError(params object[] args)
+        {
+            return PythonOps.CreateThrowable(error, args);
+        }
 
         internal static System.Text.Encoding Latin1 = System.Text.Encoding.GetEncoding("iso-8859-1");
     }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.