FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonnet/src/tests/_compat.py at master · attackgithub/pythonnet · GitHub
attackgithub
pythonnet
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
pythonnet
/
src
/
tests
/
_compat.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
74 lines (56 loc) · 1.5 KB
Breadcrumbs
pythonnet
/
src
/
tests
/
_compat.py
Copy path
File metadata and controls
74 lines (56 loc) · 1.5 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# -*- coding: utf-8 -*-
"""Python 2.7, 3.3+ compatibility module.
Using Python 3 syntax to encourage upgrade unless otherwise noted.
"""
import
operator
import
subprocess
import
sys
import
types
PY2
=
sys
.
version_info
[
0
]
==
2
PY3
=
sys
.
version_info
[
0
]
==
3
if
PY3
:
import
_thread
as
thread
# Using PY2 name
import
pickle
from
collections
import
UserList
indexbytes
=
operator
.
getitem
input
=
input
string_types
=
str
,
binary_type
=
bytes
text_type
=
str
DictProxyType
=
type
(
object
.
__dict__
)
ClassType
=
type
# No PY3 equivalents, use PY2 name
long
=
int
unichr
=
chr
unicode
=
str
# from nowhere import Nothing
cmp
=
lambda
a
,
b
: (
a
>
b
)
-
(
a
<
b
)
# No PY3 equivalent
map
=
map
range
=
range
zip
=
zip
elif
PY2
:
import
thread
# Using PY2 name
import
cPickle
as
pickle
from
UserList
import
UserList
indexbytes
=
lambda
buf
,
i
:
ord
(
buf
[
i
])
input
=
raw_input
string_types
=
str
,
unicode
bytes_type
=
str
text_type
=
unicode
DictProxyType
=
types
.
DictProxyType
ClassType
=
types
.
ClassType
# No PY3 equivalents, use PY2 name
long
=
long
unichr
=
unichr
unicode
=
unicode
from
itertools
import
izip
,
imap
cmp
=
cmp
map
=
imap
range
=
xrange
zip
=
izip
def
check_output
(
*
args
,
**
kwargs
):
"""Check output wrapper for PY2/PY3 compatibility"""
output
=
subprocess
.
check_output
(
*
args
,
**
kwargs
)
if
PY2
:
return
output
return
output
.
decode
(
"ascii"
)
Back
|
FazBrowse Home
|
New Git URL