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
8cedb89c
Commit
8cedb89c
authored
Jul 11, 2013
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Plain Diff
Merge heads
parents
6cda0adf
3687e805
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
98 additions
and
108 deletions
+98
-108
Mac/PythonLauncher/FileSettings.h
Mac/PythonLauncher/FileSettings.h
+0
-5
Mac/PythonLauncher/FileSettings.m
Mac/PythonLauncher/FileSettings.m
+20
-26
Mac/PythonLauncher/MyAppDelegate.m
Mac/PythonLauncher/MyAppDelegate.m
+3
-3
Mac/PythonLauncher/MyDocument.m
Mac/PythonLauncher/MyDocument.m
+9
-13
Mac/PythonLauncher/PreferencesWindowController.m
Mac/PythonLauncher/PreferencesWindowController.m
+10
-13
Mac/PythonLauncher/doscript.h
Mac/PythonLauncher/doscript.h
+1
-1
Mac/PythonLauncher/doscript.m
Mac/PythonLauncher/doscript.m
+39
-39
Mac/PythonLauncher/main.m
Mac/PythonLauncher/main.m
+2
-2
Misc/NEWS
Misc/NEWS
+9
-1
Objects/stringobject.c
Objects/stringobject.c
+3
-3
Python/bltinmodule.c
Python/bltinmodule.c
+2
-2
No files found.
Mac/PythonLauncher/FileSettings.h
View file @
8cedb89c
...
...
@@ -45,18 +45,13 @@
+
(
id
)
getFactorySettingsForFileType
:
(
NSString
*
)
filetype
;
+
(
id
)
newSettingsForFileType
:
(
NSString
*
)
filetype
;
//- (id)init;
-
(
id
)
initForFileType
:
(
NSString
*
)
filetype
;
-
(
id
)
initForFSDefaultFileType
:
(
NSString
*
)
filetype
;
-
(
id
)
initForDefaultFileType
:
(
NSString
*
)
filetype
;
//- (id)initWithFileSettings: (FileSettings *)source;
-
(
void
)
updateFromSource
:
(
id
<
FileSettingsSource
>
)
source
;
-
(
NSString
*
)
commandLineForScript
:
(
NSString
*
)
script
;
//- (void)applyFactorySettingsForFileType: (NSString *)filetype;
//- (void)saveDefaults;
//- (void)applyUserDefaults: (NSString *)filetype;
-
(
void
)
applyValuesFromDict
:
(
NSDictionary
*
)
dict
;
-
(
void
)
reset
;
-
(
NSArray
*
)
interpreters
;
...
...
Mac/PythonLauncher/FileSettings.m
View file @
8cedb89c
...
...
@@ -14,7 +14,7 @@
{
static
FileSettings
*
fsdefault_py
,
*
fsdefault_pyw
,
*
fsdefault_pyc
;
FileSettings
**
curdefault
;
if
([
filetype
isEqualToString
:
@"Python Script"
])
{
curdefault
=
&
fsdefault_py
;
}
else
if
([
filetype
isEqualToString
:
@"Python GUI Script"
])
{
...
...
@@ -36,7 +36,7 @@
{
static
FileSettings
*
default_py
,
*
default_pyw
,
*
default_pyc
;
FileSettings
**
curdefault
;
if
([
filetype
isEqualToString
:
@"Python Script"
])
{
curdefault
=
&
default_py
;
}
else
if
([
filetype
isEqualToString
:
@"Python GUI Script"
])
{
...
...
@@ -57,7 +57,7 @@
+
(
id
)
newSettingsForFileType
:
(
NSString
*
)
filetype
{
FileSettings
*
cur
;
cur
=
[
FileSettings
new
];
[
cur
initForFileType
:
filetype
];
return
[
cur
retain
];
...
...
@@ -67,7 +67,7 @@
{
self
=
[
super
init
];
if
(
!
self
)
return
self
;
interpreter
=
[
source
->
interpreter
retain
];
honourhashbang
=
source
->
honourhashbang
;
debug
=
source
->
debug
;
...
...
@@ -81,36 +81,30 @@
with_terminal
=
source
->
with_terminal
;
prefskey
=
source
->
prefskey
;
if
(
prefskey
)
[
prefskey
retain
];
return
self
;
}
-
(
id
)
initForFileType
:
(
NSString
*
)
filetype
{
FileSettings
*
defaults
;
defaults
=
[
FileSettings
getDefaultsForFileType
:
filetype
];
self
=
[
self
initWithFileSettings
:
defaults
];
origsource
=
[
defaults
retain
];
return
self
;
}
//- (id)init
//{
// self = [self initForFileType: @"Python Script"];
// return self;
//}
-
(
id
)
initForFSDefaultFileType
:
(
NSString
*
)
filetype
{
int
i
;
NSString
*
filename
;
NSDictionary
*
dict
;
static
NSDictionary
*
factorySettings
;
self
=
[
super
init
];
if
(
!
self
)
return
self
;
if
(
factorySettings
==
NULL
)
{
NSBundle
*
bdl
=
[
NSBundle
mainBundle
];
NSString
*
path
=
[
bdl
pathForResource
:
@"factorySettings"
...
...
@@ -149,18 +143,18 @@
{
NSUserDefaults
*
defaults
;
NSDictionary
*
dict
;
defaults
=
[
NSUserDefaults
standardUserDefaults
];
dict
=
[
defaults
dictionaryForKey
:
filetype
];
if
(
!
dict
)
return
;
[
self
applyValuesFromDict
:
dict
];
}
-
(
id
)
initForDefaultFileType
:
(
NSString
*
)
filetype
{
FileSettings
*
fsdefaults
;
fsdefaults
=
[
FileSettings
getFactorySettingsForFileType
:
filetype
];
self
=
[
self
initWithFileSettings
:
fsdefaults
];
if
(
!
self
)
return
self
;
...
...
@@ -220,7 +214,7 @@
-
(
void
)
applyValuesFromDict
:
(
NSDictionary
*
)
dict
{
id
value
;
value
=
[
dict
objectForKey
:
@"interpreter"
];
if
(
value
)
interpreter
=
[
value
retain
];
value
=
[
dict
objectForKey
:
@"honourhashbang"
];
...
...
@@ -247,12 +241,12 @@
-
(
NSString
*
)
_replaceSingleQuotes
:
(
NSString
*
)
string
{
/* Replace all single-quotes by '"'"', that way shellquoting will
* be correct when the result value is delimited using single quotes.
*/
NSArray
*
components
=
[
string
componentsSeparatedByString
:
@"'"
];
/* Replace all single-quotes by '"'"', that way shellquoting will
* be correct when the result value is delimited using single quotes.
*/
NSArray
*
components
=
[
string
componentsSeparatedByString
:
@"'"
];
return
[
components
componentsJoinedByString
:
@"'
\"
'
\"
'"
];
return
[
components
componentsJoinedByString
:
@"'
\"
'
\"
'"
];
}
-
(
NSString
*
)
commandLineForScript
:
(
NSString
*
)
script
...
...
@@ -265,7 +259,7 @@
script_dir
=
[
script
substringToIndex
:
[
script
length
]
-
[[
script
lastPathComponent
]
length
]];
if
(
honourhashbang
&&
(
fp
=
fopen
([
script
fileSystemRepresentation
],
"r"
))
&&
fgets
(
hashbangbuf
,
sizeof
(
hashbangbuf
),
fp
)
&&
...
...
@@ -278,7 +272,7 @@
}
if
(
!
cur_interp
)
cur_interp
=
interpreter
;
return
[
NSString
stringWithFormat
:
@"cd '%@' && '%@'%s%s%s%s%s%s %@ '%@' %@ %s"
,
[
self
_replaceSingleQuotes
:
script_dir
],
...
...
@@ -297,7 +291,7 @@
-
(
NSArray
*
)
interpreters
{
return
interpreters
;};
// FileSettingsSource protocol
// FileSettingsSource protocol
-
(
NSString
*
)
interpreter
{
return
interpreter
;};
-
(
BOOL
)
honourhashbang
{
return
honourhashbang
;
};
-
(
BOOL
)
debug
{
return
debug
;};
...
...
Mac/PythonLauncher/MyAppDelegate.m
View file @
8cedb89c
...
...
@@ -33,7 +33,7 @@
-
(
BOOL
)
shouldShowUI
{
// if this call comes before applicationDidFinishLaunching: we
// if this call comes before applicationDidFinishLaunching: we
// should terminate immedeately after starting the script.
if
(
!
initial_action_done
)
should_terminate
=
YES
;
...
...
@@ -62,7 +62,7 @@
static
NSString
*
extensions
[]
=
{
@"py"
,
@"pyw"
,
@"pyc"
,
NULL
};
NSString
**
ext_p
;
int
i
;
if
([[
NSUserDefaults
standardUserDefaults
]
boolForKey
:
@"SkipFileBindingTest"
])
return
;
ourUrl
=
[
NSURL
fileURLWithPath
:
[[
NSBundle
mainBundle
]
bundlePath
]];
...
...
@@ -92,5 +92,5 @@
}
}
}
@end
Mac/PythonLauncher/MyDocument.m
View file @
8cedb89c
...
...
@@ -16,7 +16,7 @@
{
self
=
[
super
init
];
if
(
self
)
{
// Add your subclass-specific initialization here.
// If an error occurs here, send a [self dealloc] message and return nil.
script
=
[
@"<no script>.py"
retain
];
...
...
@@ -37,20 +37,17 @@
{
NSApplication
*
app
=
[
NSApplication
sharedApplication
];
[
super
close
];
if
([[
app
delegate
]
shouldTerminate
])
if
([
(
MyAppDelegate
*
)
[
app
delegate
]
shouldTerminate
])
[
app
terminate
:
self
];
}
-
(
void
)
load_defaults
{
// if (settings) [settings release];
settings
=
[
FileSettings
newSettingsForFileType
:
filetype
];
}
-
(
void
)
update_display
{
// [[self window] setTitle: script];
[
interpreter
setStringValue
:
[
settings
interpreter
]];
[
honourhashbang
setState
:
[
settings
honourhashbang
]];
[
debug
setState
:
[
settings
debug
]];
...
...
@@ -62,7 +59,7 @@
[
others
setStringValue
:
[
settings
others
]];
[
scriptargs
setStringValue
:
[
settings
scriptargs
]];
[
with_terminal
setState
:
[
settings
with_terminal
]];
[
commandline
setStringValue
:
[
settings
commandLineForScript
:
script
]];
}
...
...
@@ -75,8 +72,8 @@
{
const
char
*
cmdline
;
int
sts
;
cmdline
=
[[
settings
commandLineForScript
:
script
]
c
String
];
cmdline
=
[[
settings
commandLineForScript
:
script
]
UTF8
String
];
if
([
settings
with_terminal
])
{
sts
=
doscript
(
cmdline
);
}
else
{
...
...
@@ -107,14 +104,13 @@
{
// Insert code here to read your document from the given data. You can also choose to override -loadFileWrapperRepresentation:ofType: or -readFromFile:ofType: instead.
BOOL
show_ui
;
// ask the app delegate whether we should show the UI or not.
show_ui
=
[[[
NSApplication
sharedApplication
]
delegate
]
shouldShowUI
];
// ask the app delegate whether we should show the UI or not.
show_ui
=
[
(
MyAppDelegate
*
)
[[
NSApplication
sharedApplication
]
delegate
]
shouldShowUI
];
[
script
release
];
script
=
[
fileName
retain
];
[
filetype
release
];
filetype
=
[
type
retain
];
// if (settings) [settings release];
settings
=
[
FileSettings
newSettingsForFileType
:
filetype
];
if
(
show_ui
)
{
[
self
update_display
];
...
...
@@ -152,7 +148,7 @@
[
self
update_display
];
}
// FileSettingsSource protocol
// FileSettingsSource protocol
-
(
NSString
*
)
interpreter
{
return
[
interpreter
stringValue
];};
-
(
BOOL
)
honourhashbang
{
return
[
honourhashbang
state
];};
-
(
BOOL
)
debug
{
return
[
debug
state
];};
...
...
Mac/PythonLauncher/PreferencesWindowController.m
View file @
8cedb89c
...
...
@@ -5,7 +5,7 @@
+
getPreferencesWindow
{
static
PreferencesWindowController
*
_singleton
;
if
(
!
_singleton
)
_singleton
=
[[
PreferencesWindowController
alloc
]
init
];
[
_singleton
showWindow
:
_singleton
];
...
...
@@ -21,15 +21,13 @@
-
(
void
)
load_defaults
{
NSString
*
title
=
[
filetype
titleOfSelectedItem
];
settings
=
[
FileSettings
getDefaultsForFileType
:
title
];
}
-
(
void
)
update_display
{
// [[self window] setTitle: script];
[
interpreter
reloadData
];
[
interpreter
reloadData
];
[
interpreter
setStringValue
:
[
settings
interpreter
]];
[
honourhashbang
setState
:
[
settings
honourhashbang
]];
[
debug
setState
:
[
settings
debug
]];
...
...
@@ -41,7 +39,6 @@
[
others
setStringValue
:
[
settings
others
]];
[
with_terminal
setState
:
[
settings
with_terminal
]];
// Not scriptargs, it isn't for preferences
[
commandline
setStringValue
:
[
settings
commandLineForScript
:
@"<your script here>"
]];
}
...
...
@@ -75,7 +72,7 @@
[
self
update_display
];
}
// FileSettingsSource protocol
// FileSettingsSource protocol
-
(
NSString
*
)
interpreter
{
return
[
interpreter
stringValue
];};
-
(
BOOL
)
honourhashbang
{
return
[
honourhashbang
state
];
};
-
(
BOOL
)
debug
{
return
[
debug
state
];};
...
...
@@ -98,23 +95,23 @@
// NSComboBoxDataSource protocol
-
(
unsigned
int
)
comboBox
:(
NSComboBox
*
)
aComboBox
indexOfItemWithStringValue
:(
NSString
*
)
aString
{
NSArray
*
interp_list
=
[
settings
interpreters
];
NSArray
*
interp_list
=
[
settings
interpreters
];
unsigned
int
rv
=
[
interp_list
indexOfObjectIdenticalTo
:
aString
];
return
rv
;
return
rv
;
}
-
(
id
)
comboBox
:(
NSComboBox
*
)
aComboBox
objectValueForItemAtIndex
:(
int
)
index
{
NSArray
*
interp_list
=
[
settings
interpreters
];
NSArray
*
interp_list
=
[
settings
interpreters
];
id
rv
=
[
interp_list
objectAtIndex
:
index
];
return
rv
;
return
rv
;
}
-
(
int
)
numberOfItemsInComboBox
:(
NSComboBox
*
)
aComboBox
{
NSArray
*
interp_list
=
[
settings
interpreters
];
NSArray
*
interp_list
=
[
settings
interpreters
];
int
rv
=
[
interp_list
count
];
return
rv
;
return
rv
;
}
...
...
Mac/PythonLauncher/doscript.h
View file @
8cedb89c
...
...
@@ -9,4 +9,4 @@
#include <Carbon/Carbon.h>
extern
int
doscript
(
const
char
*
command
);
\ No newline at end of file
extern
int
doscript
(
const
char
*
command
);
Mac/PythonLauncher/doscript.m
View file @
8cedb89c
...
...
@@ -11,49 +11,49 @@
#import <ApplicationServices/ApplicationServices.h>
#import "doscript.h"
extern
int
extern
int
doscript
(
const
char
*
command
)
{
char
*
bundleID
=
"com.apple.Terminal"
;
AppleEvent
evt
,
res
;
AEDesc
desc
;
OSStatus
err
;
char
*
bundleID
=
"com.apple.Terminal"
;
AppleEvent
evt
,
res
;
AEDesc
desc
;
OSStatus
err
;
[[
NSWorkspace
sharedWorkspace
]
launchApplication
:
@"/Applications/Utilities/Terminal.app/"
];
[[
NSWorkspace
sharedWorkspace
]
launchApplication
:
@"/Applications/Utilities/Terminal.app/"
];
// Build event
err
=
AEBuildAppleEvent
(
kAECoreSuite
,
kAEDoScript
,
typeApplicationBundleID
,
bundleID
,
strlen
(
bundleID
),
kAutoGenerateReturnID
,
kAnyTransactionID
,
&
evt
,
NULL
,
"'----':utf8(@)"
,
strlen
(
command
),
command
);
if
(
err
)
{
NSLog
(
@"AEBuildAppleEvent failed: %d
\n
"
,
err
);
return
err
;
}
// Build event
err
=
AEBuildAppleEvent
(
kAECoreSuite
,
kAEDoScript
,
typeApplicationBundleID
,
bundleID
,
strlen
(
bundleID
),
kAutoGenerateReturnID
,
kAnyTransactionID
,
&
evt
,
NULL
,
"'----':utf8(@)"
,
strlen
(
command
),
command
);
if
(
err
)
{
NSLog
(
@"AEBuildAppleEvent failed: %ld
\n
"
,
(
long
)
err
);
return
err
;
}
// Send event and check for any Apple Event Manager errors
err
=
AESendMessage
(
&
evt
,
&
res
,
kAEWaitReply
,
kAEDefaultTimeout
);
AEDisposeDesc
(
&
evt
);
if
(
err
)
{
NSLog
(
@"AESendMessage failed: %d
\n
"
,
err
);
return
err
;
}
// Check for any application errors
err
=
AEGetParamDesc
(
&
res
,
keyErrorNumber
,
typeSInt32
,
&
desc
);
AEDisposeDesc
(
&
res
);
if
(
!
err
)
{
AEGetDescData
(
&
desc
,
&
err
,
sizeof
(
err
));
NSLog
(
@"Terminal returned an error: %d"
,
err
);
AEDisposeDesc
(
&
desc
);
}
else
if
(
err
==
errAEDescNotFound
)
{
err
=
noErr
;
}
else
{
NSLog
(
@"AEGetPArmDesc returned an error: %d"
,
err
);
}
// Send event and check for any Apple Event Manager errors
err
=
AESendMessage
(
&
evt
,
&
res
,
kAEWaitReply
,
kAEDefaultTimeout
);
AEDisposeDesc
(
&
evt
);
if
(
err
)
{
NSLog
(
@"AESendMessage failed: %ld
\n
"
,
(
long
)
err
);
return
err
;
}
// Check for any application errors
err
=
AEGetParamDesc
(
&
res
,
keyErrorNumber
,
typeSInt32
,
&
desc
);
AEDisposeDesc
(
&
res
);
if
(
!
err
)
{
AEGetDescData
(
&
desc
,
&
err
,
sizeof
(
err
));
NSLog
(
@"Terminal returned an error: %ld"
,
(
long
)
err
);
AEDisposeDesc
(
&
desc
);
}
else
if
(
err
==
errAEDescNotFound
)
{
err
=
noErr
;
}
else
{
NSLog
(
@"AEGetPArmDesc returned an error: %ld"
,
(
long
)
err
);
}
return
err
;
return
err
;
}
Mac/PythonLauncher/main.m
View file @
8cedb89c
...
...
@@ -11,7 +11,7 @@
int main(int argc, const char *argv[])
{
char *home = getenv("HOME");
if (home) chdir(home);
char *home = getenv("HOME");
if (home) chdir(home);
return NSApplicationMain(argc, argv);
}
Misc/NEWS
View file @
8cedb89c
...
...
@@ -24,6 +24,8 @@ Core and Builtins
Library
-------
- Issue #18427: str.replace could crash the interpreter with huge strings.
- Issue #18347: ElementTree'
s
html
serializer
now
preserves
the
case
of
closing
tags
.
...
...
@@ -67,6 +69,12 @@ Library
- Issue #18113: Fixed a refcount leak in the curses.panel module'
s
set_userptr
()
method
.
Reported
by
Atsuo
Ishimoto
.
Tools
/
Demos
-----------
-
Issue
#
12990
:
The
"Python Launcher"
on
OSX
could
not
launch
python
scripts
that
have
paths
that
include
wide
characters
.
Build
-----
...
...
@@ -82,7 +90,7 @@ IDLE
-
Issue
#
7136
:
In
the
Idle
File
menu
,
"New Window"
is
renamed
"New File"
.
Patch
by
Tal
Einat
,
Roget
Serwy
,
and
Todd
Rovito
.
-
Issue
#
8515
:
Set
__file__
when
run
file
in
IDLE
.
Initial
patch
by
Bruce
Frederiksen
.
...
...
Objects/stringobject.c
View file @
8cedb89c
...
...
@@ -882,9 +882,9 @@ string_print(PyStringObject *op, FILE *fp, int flags)
size
-=
chunk_size
;
}
#ifdef __VMS
if
(
size
)
fwrite
(
data
,
(
in
t
)
size
,
1
,
fp
);
if
(
size
)
fwrite
(
data
,
(
size_
t
)
size
,
1
,
fp
);
#else
fwrite
(
data
,
1
,
(
in
t
)
size
,
fp
);
fwrite
(
data
,
1
,
(
size_
t
)
size
,
fp
);
#endif
Py_END_ALLOW_THREADS
return
0
;
...
...
@@ -2332,7 +2332,7 @@ return_self(PyStringObject *self)
}
Py_LOCAL_INLINE
(
Py_ssize_t
)
countchar
(
const
char
*
target
,
in
t
target_len
,
char
c
,
Py_ssize_t
maxcount
)
countchar
(
const
char
*
target
,
Py_ssize_
t
target_len
,
char
c
,
Py_ssize_t
maxcount
)
{
Py_ssize_t
count
=
0
;
const
char
*
start
=
target
;
...
...
Python/bltinmodule.c
View file @
8cedb89c
...
...
@@ -2434,9 +2434,9 @@ builtin_sum(PyObject *self, PyObject *args)
PyDoc_STRVAR
(
sum_doc
,
"sum(sequence[, start]) -> value
\n
\
\n
\
Return
s
the sum of a sequence of numbers (NOT strings) plus the value
\n
\
Return the sum of a sequence of numbers (NOT strings) plus the value
\n
\
of parameter 'start' (which defaults to 0). When the sequence is
\n
\
empty, return
s
start."
);
empty, return start."
);
static
PyObject
*
...
...
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