Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
548deaf2
Commit
548deaf2
authored
May 30, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove usage of deprecated "U" file open mode flag which is enabled anyway
parent
d6109ba4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
32 deletions
+13
-32
Cython/Build/Dependencies.py
Cython/Build/Dependencies.py
+1
-1
Cython/Compiler/Main.py
Cython/Compiler/Main.py
+2
-8
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+3
-6
Cython/Compiler/Scanning.py
Cython/Compiler/Scanning.py
+3
-8
Cython/Utils.py
Cython/Utils.py
+4
-9
No files found.
Cython/Build/Dependencies.py
View file @
548deaf2
...
...
@@ -399,7 +399,7 @@ def parse_dependencies(source_filename):
# Actual parsing is way to slow, so we use regular expressions.
# The only catch is that we must strip comments and string
# literals ahead of time.
fh
=
Utils
.
open_source_file
(
source_filename
,
"rU"
,
error_handling
=
'ignore'
)
fh
=
Utils
.
open_source_file
(
source_filename
,
error_handling
=
'ignore'
)
try
:
source
=
fh
.
read
()
finally
:
...
...
Cython/Compiler/Main.py
View file @
548deaf2
...
...
@@ -336,8 +336,7 @@ class Context(object):
# Parse the given source file and return a parse tree.
num_errors
=
Errors
.
num_errors
try
:
f
=
Utils
.
open_source_file
(
source_filename
,
"rU"
)
try
:
with
Utils
.
open_source_file
(
source_filename
)
as
f
:
from
.
import
Parsing
s
=
PyrexScanner
(
f
,
source_desc
,
source_encoding
=
f
.
encoding
,
scope
=
scope
,
context
=
self
)
...
...
@@ -349,8 +348,6 @@ class Context(object):
raise
RuntimeError
(
"Formal grammer can only be used with compiled Cython with an available pgen."
)
ConcreteSyntaxTree
.
p_module
(
source_filename
)
finally
:
f
.
close
()
except
UnicodeDecodeError
,
e
:
#import traceback
#traceback.print_exc()
...
...
@@ -360,11 +357,8 @@ class Context(object):
position
=
e
.
args
[
2
]
encoding
=
e
.
args
[
0
]
f
=
open
(
source_filename
,
"rb"
)
try
:
with
open
(
source_filename
,
"rb"
)
as
f
:
byte_data
=
f
.
read
()
finally
:
f
.
close
()
# FIXME: make this at least a little less inefficient
for
idx
,
c
in
enumerate
(
byte_data
):
...
...
Cython/Compiler/Parsing.py
View file @
548deaf2
...
...
@@ -1768,13 +1768,10 @@ def p_include_statement(s, ctx):
include_file_path
=
s
.
context
.
find_include_file
(
include_file_name
,
pos
)
if
include_file_path
:
s
.
included_files
.
append
(
include_file_name
)
f
=
Utils
.
open_source_file
(
include_file_path
,
mode
=
"rU"
)
source_desc
=
FileSourceDescriptor
(
include_file_path
)
s2
=
PyrexScanner
(
f
,
source_desc
,
s
,
source_encoding
=
f
.
encoding
,
parse_comments
=
s
.
parse_comments
)
try
:
with
Utils
.
open_source_file
(
include_file_path
)
as
f
:
source_desc
=
FileSourceDescriptor
(
include_file_path
)
s2
=
PyrexScanner
(
f
,
source_desc
,
s
,
source_encoding
=
f
.
encoding
,
parse_comments
=
s
.
parse_comments
)
tree
=
p_statement_list
(
s2
,
ctx
)
finally
:
f
.
close
()
return
tree
else
:
return
None
...
...
Cython/Compiler/Scanning.py
View file @
548deaf2
...
...
@@ -199,15 +199,10 @@ class FileSourceDescriptor(SourceDescriptor):
return
lines
except
KeyError
:
pass
f
=
Utils
.
open_source_file
(
self
.
filename
,
encoding
=
encoding
,
error_handling
=
error_handling
,
# newline normalisation is costly before Py2.6
require_normalised_newlines
=
False
)
try
:
with
Utils
.
open_source_file
(
self
.
filename
,
encoding
=
encoding
,
error_handling
=
error_handling
)
as
f
:
lines
=
list
(
f
)
finally
:
f
.
close
()
if
key
in
self
.
_lines
:
self
.
_lines
[
key
]
=
lines
else
:
...
...
Cython/Utils.py
View file @
548deaf2
...
...
@@ -244,16 +244,13 @@ def skip_bom(f):
def
open_source_file
(
source_filename
,
mode
=
"r"
,
encoding
=
None
,
error_handling
=
None
,
require_normalised_newlines
=
True
):
encoding
=
None
,
error_handling
=
None
):
if
encoding
is
None
:
# Most of the time the coding is unspecified, so be optimistic that
# it's UTF-8.
f
=
open_source_file
(
source_filename
,
encoding
=
"UTF-8"
,
mode
=
mode
,
error_handling
=
'ignore'
)
encoding
=
detect_opened_file_encoding
(
f
)
if
(
encoding
==
"UTF-8"
and
error_handling
==
'ignore'
and
require_normalised_newlines
):
if
encoding
==
"UTF-8"
and
error_handling
==
'ignore'
:
f
.
seek
(
0
)
skip_bom
(
f
)
return
f
...
...
@@ -266,8 +263,7 @@ def open_source_file(source_filename, mode="r",
if
source_filename
.
startswith
(
loader
.
archive
):
return
open_source_from_loader
(
loader
,
source_filename
,
encoding
,
error_handling
,
require_normalised_newlines
)
encoding
,
error_handling
)
except
(
NameError
,
AttributeError
):
pass
...
...
@@ -279,8 +275,7 @@ def open_source_file(source_filename, mode="r",
def
open_source_from_loader
(
loader
,
source_filename
,
encoding
=
None
,
error_handling
=
None
,
require_normalised_newlines
=
True
):
encoding
=
None
,
error_handling
=
None
):
nrmpath
=
os
.
path
.
normpath
(
source_filename
)
arcname
=
nrmpath
[
len
(
loader
.
archive
)
+
1
:]
data
=
loader
.
get_data
(
arcname
)
...
...
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