From: Sergey Matveev Date: Thu, 7 May 2020 17:20:04 +0000 (+0300) Subject: Hide mmap imports, failing on Windows X-Git-Tag: 8.1^0 X-Git-Url: http://www.git.cypherpunks.ru/?p=pyderasn.git;a=commitdiff_plain;h=7c53a135eccaf1f2dfcff835b799183ae4998f0e Hide mmap imports, failing on Windows --- diff --git a/VERSION b/VERSION index cc40bca..b8eb026 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.0 +8.1 diff --git a/doc/install.rst b/doc/install.rst index 05a9147..7ec013b 100644 --- a/doc/install.rst +++ b/doc/install.rst @@ -4,11 +4,11 @@ Install Preferable way is to :ref:`download ` tarball with the signature from `official website `__:: - $ [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 ` page. You could use pip (**no** OpenPGP authentication is performed!) with PyPI:: $ cat > requirements.txt <`_ for huge quantity of improvement ideas +* `Evgeny Drobotun `_ for testing under Windows + and bugreporting diff --git a/pyderasn.py b/pyderasn.py index 516715a..4b690f7 100755 --- a/pyderasn.py +++ b/pyderasn.py @@ -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 ()