Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
makefile.py
Go to the documentation of this file.
1
# -*- coding: utf-8 -*-
2
"""
3
backports.makefile
4
~~~~~~~~~~~~~~~~~~
5
6
Backports the Python 3 ``socket.makefile`` method for use with anything that
7
wants to create a "fake" socket object.
8
"""
9
import
io
10
from
socket
import
SocketIO
11
12
13
def
backport_makefile(
14
self, mode="r", buffering=None, encoding=None, errors=None, newline=None
15
):
16
"""
17
Backport of ``socket.makefile`` from Python 3.5.
18
"""
19
if
not
set(mode) <= {
"r"
,
"w"
,
"b"
}:
20
raise
ValueError(
"invalid mode %r (only r, w, b allowed)"
% (mode,))
21
writing =
"w"
in
mode
22
reading =
"r"
in
mode
or
not
writing
23
assert
reading
or
writing
24
binary =
"b"
in
mode
25
rawmode =
""
26
if
reading:
27
rawmode +=
"r"
28
if
writing:
29
rawmode +=
"w"
30
raw = SocketIO(self, rawmode)
31
self._makefile_refs += 1
32
if
buffering
is
None
:
33
buffering = -1
34
if
buffering < 0:
35
buffering =
io.DEFAULT_BUFFER_SIZE
36
if
buffering == 0:
37
if
not
binary:
38
raise
ValueError(
"unbuffered streams must be binary"
)
39
return
raw
40
if
reading
and
writing:
41
buffer =
io.BufferedRWPair
(raw, raw, buffering)
42
elif
reading:
43
buffer =
io.BufferedReader
(raw, buffering)
44
else
:
45
assert
writing
46
buffer =
io.BufferedWriter
(raw, buffering)
47
if
binary:
48
return
buffer
49
text =
io.TextIOWrapper
(buffer, encoding, errors, newline)
50
text.mode
= mode
51
return
text
i
for i
Definition
prime_search.m:10
venv
lib
python3.12
site-packages
pip
_vendor
urllib3
packages
backports
makefile.py
Generated by
1.9.8