]> Cypherpunks.ru repositories - pyderasn.git/commitdiff
Hide mmap imports, failing on Windows 8.1
authorSergey Matveev <stargrave@stargrave.org>
Thu, 7 May 2020 17:20:04 +0000 (20:20 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Fri, 8 May 2020 08:33:55 +0000 (11:33 +0300)
VERSION
doc/install.rst
doc/news.rst
doc/thanks.rst
pyderasn.py

diff --git a/VERSION b/VERSION
index cc40bca69a0ca08256b17fdb5f4a1210364ea597..b8eb0263502da49751d19c5e9867e220a58cd5f3 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-8.0
+8.1
index 05a9147d44a537d98bfe1bd9a76c2a75d0b3885f..7ec013bd59ae05b42285678afb75f52ee25bf8ec 100644 (file)
@@ -4,11 +4,11 @@ Install
 Preferable way is to :ref:`download <download>` tarball with the
 signature from `official website <http://pyderasn.cypherpunks.ru/>`__::
 
-    $ [fetch|wget] http://pyderasn.cypherpunks.ru/pyderasn-8.0.tar.xz
-    $ [fetch|wget] http://pyderasn.cypherpunks.ru/pyderasn-8.0.tar.xz.sig
-    $ gpg --verify pyderasn-8.0.tar.xz.sig pyderasn-8.0.tar.xz
-    $ xz --decompress --stdout pyderasn-8.0.tar.xz | tar xf -
-    $ cd pyderasn-8.0
+    $ [fetch|wget] http://pyderasn.cypherpunks.ru/pyderasn-8.1.tar.xz
+    $ [fetch|wget] http://pyderasn.cypherpunks.ru/pyderasn-8.1.tar.xz.sig
+    $ gpg --verify pyderasn-8.1.tar.xz.sig pyderasn-8.1.tar.xz
+    $ xz --decompress --stdout pyderasn-8.1.tar.xz | tar xf -
+    $ cd pyderasn-8.1
     $ python setup.py install
     # or copy pyderasn.py (+six.py, possibly termcolor.py) to your PYTHONPATH
 
@@ -21,7 +21,7 @@ You can also find it mirrored on :ref:`download <download>` page.
 You could use pip (**no** OpenPGP authentication is performed!) with PyPI::
 
     $ cat > requirements.txt <<EOF
-    pyderasn==8.0 --hash=sha256:TO-BE-FILLED
+    pyderasn==8.1 --hash=sha256:TO-BE-FILLED
     six==1.14.0 --hash=sha256:236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a
     EOF
     $ pip install --requirement requirements.txt
index d93a1f795c433fd20bc8ccf3d68660003d086161..dd587b70a285c992e30bd6b7fc45fcd9bda7a3be 100644 (file)
@@ -1,6 +1,14 @@
 News
 ====
 
+.. _release8.1:
+
+8.1
+---
+* Workability under Microsoft Windows OS should be restored: it has
+  different ``mmap`` constants and implementation, preventing
+  ``pyderasn`` importing
+
 .. _release8.0:
 
 8.0
index 57e9d4d255a661685042633e94387156de3ac1b0..fa141564448bbc07b0136d4c59f7c507e3074e79 100644 (file)
@@ -7,3 +7,5 @@ Thanks
   :py:class:`pyderasn.AutoAddSlots` metaclass
 * `Tim Perevezentsev <riffm2005@gmail.com>`_ for huge quantity of
   improvement ideas
+* `Evgeny Drobotun <drobotun@xakep.ru>`_ for testing under Windows
+  and bugreporting
index 516715a7f2e419a6d1070c03eee7f2c07bb1b895..4b690f72b1ed1ec2c1c20e59b6f3acdd7620f262 100755 (executable)
@@ -1170,8 +1170,6 @@ from datetime import datetime
 from datetime import timedelta
 from io import BytesIO
 from math import ceil
-from mmap import mmap
-from mmap import PROT_READ
 from operator import attrgetter
 from string import ascii_letters
 from string import digits
@@ -1201,7 +1199,7 @@ except ImportError:  # pragma: no cover
     def colored(what, *args, **kwargs):
         return what
 
-__version__ = "8.0"
+__version__ = "8.1"
 
 __all__ = (
     "agg_octet_string",
@@ -1292,8 +1290,13 @@ def file_mmaped(fd):
 
     :param fd: file object
     :returns: memoryview over read-only mmap-ing of the whole file
+
+    .. warning::
+
+       It is known to work under neither Python 2.x nor Windows.
     """
-    return memoryview(mmap(fd.fileno(), 0, prot=PROT_READ))
+    import mmap
+    return memoryview(mmap.mmap(fd.fileno(), length=0, prot=mmap.PROT_READ))
 
 
 def pureint(value):
@@ -7897,12 +7900,12 @@ def main():  # pragma: no cover
         help="Path to BER/CER/DER file you want to decode",
     )
     args = parser.parse_args()
-    if PY2:
+    try:
+        raw = file_mmaped(args.RAWFile)[args.skip:]
+    except:
         args.RAWFile.seek(args.skip)
         raw = memoryview(args.RAWFile.read())
         args.RAWFile.close()
-    else:
-        raw = file_mmaped(args.RAWFile)[args.skip:]
     oid_maps = (
         [obj_by_path(_path) for _path in (args.oids or "").split(",")]
         if args.oids else ()