Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
5d0bd1eb
Commit
5d0bd1eb
authored
Nov 26, 2002
by
Just van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor universal line endings detection
parent
39b48523
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
Tools/freeze/modulefinder.py
Tools/freeze/modulefinder.py
+8
-8
No files found.
Tools/freeze/modulefinder.py
View file @
5d0bd1eb
...
...
@@ -9,6 +9,12 @@ import os
import
sys
import
new
if
hasattr
(
sys
.
__stdout__
,
"newlines"
):
READ_MODE
=
"U"
# universal line endings
else
:
# remain compatible with Python < 2.3
READ_MODE
=
"r"
IMPORT_NAME
=
dis
.
opname
.
index
(
'IMPORT_NAME'
)
IMPORT_FROM
=
dis
.
opname
.
index
(
'IMPORT_FROM'
)
STORE_NAME
=
dis
.
opname
.
index
(
'STORE_NAME'
)
...
...
@@ -95,20 +101,14 @@ class ModuleFinder:
def
run_script
(
self
,
pathname
):
self
.
msg
(
2
,
"run_script"
,
pathname
)
if
hasattr
(
sys
.
stdout
,
"newlines"
):
# detect universal newline support
fp
=
open
(
pathname
,
"U"
)
else
:
fp
=
open
(
pathname
,
"r"
)
fp
=
open
(
pathname
,
READ_MODE
)
stuff
=
(
""
,
"r"
,
imp
.
PY_SOURCE
)
self
.
load_module
(
'__main__'
,
fp
,
pathname
,
stuff
)
def
load_file
(
self
,
pathname
):
dir
,
name
=
os
.
path
.
split
(
pathname
)
name
,
ext
=
os
.
path
.
splitext
(
name
)
if
hasattr
(
sys
.
stdout
,
"newlines"
):
fp
=
open
(
pathname
,
"U"
)
else
:
fp
=
open
(
pathname
,
"r"
)
fp
=
open
(
pathname
,
READ_MODE
)
stuff
=
(
ext
,
"r"
,
imp
.
PY_SOURCE
)
self
.
load_module
(
name
,
fp
,
pathname
,
stuff
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment