Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit82b39bf

Browse files
author
lrraymond13
committed
Fixed#284
1 parent89b1863 commit82b39bf

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

‎bpython/args.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ def parse(args, extras=None, ignore_stdin=False):
9090

9191
ifnotignore_stdinandnot (sys.stdin.isatty()andsys.stdout.isatty()):
9292
interpreter=code.InteractiveInterpreter()
93+
print"Entering st.read %s"%sys.stdout.isatty()
9394
interpreter.runsource(sys.stdin.read())
9495
raiseSystemExit
9596

@@ -107,5 +108,6 @@ def exec_code(interpreter, args):
107108
source=sourcefile.read()
108109
old_argv,sys.argv=sys.argv,args
109110
sys.path.insert(0,os.path.abspath(os.path.dirname(args[0])))
111+
interpreter.locals['__file__']=args[0]
110112
interpreter.runsource(source,args[0],'exec')
111113
sys.argv=old_argv

‎bpython/test/test_args.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
importunittest
2+
importsubprocess
3+
importtempfile
4+
importsys
5+
6+
7+
8+
9+
classTestExecArgs(unittest.TestCase):
10+
deftest_exec_dunder_file(self):
11+
withtempfile.NamedTemporaryFile(delete=False)asf:
12+
f.write(
13+
"import sys; print 'hello'; sys.stderr.write(__file__); sys.stderr.flush();")
14+
f.flush()
15+
printopen(f.name).read()
16+
p=subprocess.Popen(['bpython-curtsies',f.name],stderr=subprocess.PIPE)
17+
18+
self.assertEquals(p.stderr.read().strip(),f.name)
19+
20+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp