[PyObjC-svn] r2602 - in branches/pyobjc-2.3.x: . pyobjc-core/Examples/NonFunctional/RemotePyInterpreter pyobjc-core/Examples/Scripts pyobjc-framework-Cocoa/Examples/AppKit/PyObjCLauncher pyobjc-framework-Cocoa/Examples/AppKit/SimpleService pyobjc-framework-Cocoa/Examples/AppKit/TinyURLService pyobjc-framework-ExceptionHandling/Lib/PyObjCTools
[email protected] Tue, 12 Oct 2010 12:24:14 -0500
| Newsgroups | gmane.comp.python.pyobjc.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: ronaldoussoren
Date: Tue Oct 12 12:24:14 2010
New Revision: 2602
Log:
Merged revisions 2601 via svnmerge from
https://svn.red-bean.com/pyobjc/trunk/pyobjc
........
r2601 | ronaldoussoren | 2010-10-12 19:20:20 +0200 (Tue, 12 Oct 2010) | 10 lines
Ensure that NSLog calls are safe.
In early versions of PyObjC we didn't support format strings but always
called ``NSLog(@"%s", pythonArgument)``. This was changed in PyObjC 2,
and that made calling NSLog with a non-constant first argument unsafe.
This patch fixes that problem.
Based on issue #3085651 on SF.net
........
Modified:
branches/pyobjc-2.3.x/ (props changed)
branches/pyobjc-2.3.x/pyobjc-core/Examples/NonFunctional/RemotePyInterpreter/AsyncPythonInterpreter.py
branches/pyobjc-2.3.x/pyobjc-core/Examples/NonFunctional/RemotePyInterpreter/ConsoleReactor.py
branches/pyobjc-2.3.x/pyobjc-core/Examples/NonFunctional/RemotePyInterpreter/RemotePyInterpreter.py
branches/pyobjc-2.3.x/pyobjc-core/Examples/Scripts/autoreadme.py
branches/pyobjc-2.3.x/pyobjc-framework-Cocoa/Examples/AppKit/PyObjCLauncher/FileSettings.py
branches/pyobjc-2.3.x/pyobjc-framework-Cocoa/Examples/AppKit/PyObjCLauncher/MyDocument.py
branches/pyobjc-2.3.x/pyobjc-framework-Cocoa/Examples/AppKit/SimpleService/ServiceTest.py
branches/pyobjc-2.3.x/pyobjc-framework-Cocoa/Examples/AppKit/SimpleService/SimpleService_main.py
branches/pyobjc-2.3.x/pyobjc-framework-Cocoa/Examples/AppKit/TinyURLService/TinyURLService.py
branches/pyobjc-2.3.x/pyobjc-framework-ExceptionHandling/Lib/PyObjCTools/Debugging.py
Modified: branches/pyobjc-2.3.x/pyobjc-core/Examples/NonFunctional/RemotePyInterpreter/AsyncPythonInterpreter.py
==============================================================================
--- branches/pyobjc-2.3.x/pyobjc-core/Examples/NonFunctional/RemotePyInterpreter/AsyncPythonInterpreter.py (original)
+++ branches/pyobjc-2.3.x/pyobjc-core/Examples/NonFunctional/RemotePyInterpreter/AsyncPythonInterpreter.py Tue Oct 12 12:24:14 2010
@@ -74,7 +74,7 @@
try:
rval = typeCheck(rval)
except TypeError:
- NSLog(u'%s failed type check %s with value %r' % (k, typeCheck.__name__, rval))
+ NSLog(u'%s failed type check %s with value %s', k, typeCheck.__name__, rval)
rval = None
if rval is None:
defaults.setObject_forKey_(v, k)
@@ -131,7 +131,7 @@
newData = ui.objectForKey_(NSFileHandleNotificationDataItem)
if newData is None:
self.close()
- NSLog(u'Error: %r' % (ui.objectForKey_(NSFileHandleError),))
+ NSLog(u'Error: %@', ui.objectForKey_(NSFileHandleError))
return
bytes = newData.bytes()[:]
if len(bytes) == 0:
@@ -140,7 +140,7 @@
self.remoteFileHandle.readInBackgroundAndNotify()
start = len(self.buffer)
buff = self.buffer + newData.bytes()[:]
- #NSLog(u'current buffer: %r' % (buff,))
+ #NSLog(u'current buffer: %s', buff)
lines = []
while True:
linebreak = buff.find('\n', start) + 1
@@ -149,13 +149,13 @@
lines.append(buff[:linebreak])
buff = buff[linebreak:]
start = 0
- #NSLog(u'lines: %r' % (lines,))
+ #NSLog(u'lines: %s', lines)
self.buffer = buff
for line in lines:
self.commandReactor.lineReceived_fromConnection_(line, self)
def writeBytes_(self, bytes):
- #NSLog(u'Writing bytes: %r' % (bytes,))
+ #NSLog(u'Writing bytes: %s' bytes)
try:
self.remoteFileHandle.writeData_(NSData.dataWithBytes_length_(bytes, len(bytes)))
except objc.error:
Modified: branches/pyobjc-2.3.x/pyobjc-core/Examples/NonFunctional/RemotePyInterpreter/ConsoleReactor.py
==============================================================================
--- branches/pyobjc-2.3.x/pyobjc-core/Examples/NonFunctional/RemotePyInterpreter/ConsoleReactor.py (original)
+++ branches/pyobjc-2.3.x/pyobjc-core/Examples/NonFunctional/RemotePyInterpreter/ConsoleReactor.py Tue Oct 12 12:24:14 2010
@@ -52,7 +52,7 @@
sel = 'handle%sCommand:' % (basic.capitalize())
cmd = command[1:]
if not self.respondsToSelector_(sel):
- NSLog(u'%r does not respond to %r' % (self, command))
+ NSLog(u'%r does not respond to %s', self, command)
else:
# XXX - this crashes PyObjC??
# self.performSelector_withObject_(sel, cmd)
@@ -119,7 +119,7 @@
elif name == 'RemoteConsole.initialize':
self.doCallback_sequence_args_(lambda *args:None, seq, args)
else:
- self.doCallback_sequence_args_(NSLog, seq, [u'%r does not respond to expect %r' % (self, command,)])
+ self.doCallback_sequence_args_(NSLog, seq, [u'%r does not respond to expect %r', self, command,])
def close(self):
if self.connection is not None:
Modified: branches/pyobjc-2.3.x/pyobjc-core/Examples/NonFunctional/RemotePyInterpreter/RemotePyInterpreter.py
==============================================================================
--- branches/pyobjc-2.3.x/pyobjc-core/Examples/NonFunctional/RemotePyInterpreter/RemotePyInterpreter.py (original)
+++ branches/pyobjc-2.3.x/pyobjc-core/Examples/NonFunctional/RemotePyInterpreter/RemotePyInterpreter.py Tue Oct 12 12:24:14 2010
@@ -59,7 +59,7 @@
self.delegate.expectCodeInput_withPrompt_(input_received, '')
else:
- self.doCallback_sequence_args_(NSLog, seq, [u'%r does not respond to expect %r' % (self, command,)])
+ self.doCallback_sequence_args_(NSLog, seq, [u'%s does not respond to expect %s', self, command])
elif name == 'RemoteConsole.initialize':
def gotTitle(repr_versioninfo, executable, pid):
self.delegate.setVersion_executable_pid_(
@@ -72,7 +72,7 @@
# meth = getattr(fh, name[len('RemoteFileLike.'):])
# self.doCallback_sequence_args_(meth, seq, args[1:])
else:
- self.doCallback_sequence_args_(NSLog, seq, [u'%r does not respond to expect %r' % (self, command,)])
+ self.doCallback_sequence_args_(NSLog, seq, [u'%s does not respond to expect %s', self, command])
def close(self):
super(RemotePyInterpreterReactor, self).close()
Modified: branches/pyobjc-2.3.x/pyobjc-core/Examples/Scripts/autoreadme.py
==============================================================================
--- branches/pyobjc-2.3.x/pyobjc-core/Examples/Scripts/autoreadme.py (original)
+++ branches/pyobjc-2.3.x/pyobjc-core/Examples/Scripts/autoreadme.py Tue Oct 12 12:24:14 2010
@@ -38,8 +38,8 @@
success, app, None = workspace.getInfoForFile_application_type_(
fullPath)
if not success:
- NSLog("Failed to find application to open file %s"%(
- fullPath,))
+ NSLog("Failed to find application to open file %s",
+ fullPath)
return
workspace.openFile_withApplication_(fullPath, app)
Modified: branches/pyobjc-2.3.x/pyobjc-framework-Cocoa/Examples/AppKit/PyObjCLauncher/FileSettings.py
==============================================================================
--- branches/pyobjc-2.3.x/pyobjc-framework-Cocoa/Examples/AppKit/PyObjCLauncher/FileSettings.py (original)
+++ branches/pyobjc-2.3.x/pyobjc-framework-Cocoa/Examples/AppKit/PyObjCLauncher/FileSettings.py Tue Oct 12 12:24:14 2010
@@ -20,7 +20,7 @@
elif filetype == u'Python Bytecode Document':
curdefault = cls.fsdefault_pyc
else:
- NSLog(u'Funny File Type: %s\n' % (filetype,))
+ NSLog(u'Funny File Type: %s\n', filetype)
curdefault = cls.fsdefault_py
filetype = u'Python Script'
if curdefault is None:
@@ -36,7 +36,7 @@
elif filetype == u'Python Bytecode Document':
curdefault = cls.default_pyc
else:
- NSLog(u'Funny File Type: %s\n' % (filetype,))
+ NSLog(u'Funny File Type: %s', filetype)
curdefault = cls.default_py
filetype = u'Python Script'
if curdefault is None:
@@ -67,11 +67,11 @@
path = bndl.pathForResource_ofType_(u'factorySettings', u'plist')
type(self).factorySettings = NSDictionary.dictionaryWithContentsOfFile_(path)
if type(self).factorySettings is None:
- NSLog(u'Missing %s' % (path,))
+ NSLog(u'Missing %s', path)
return None
dct = type(self).factorySettings.get(filetype)
if dct is None:
- NSLog(u'factorySettings.plist misses file type "%s"' % (filetype,))
+ NSLog(u'factorySettings.plist misses file type "%s"', filetype)
return None
self.applyValuesFromDict_(dct)
Modified: branches/pyobjc-2.3.x/pyobjc-framework-Cocoa/Examples/AppKit/PyObjCLauncher/MyDocument.py
==============================================================================
--- branches/pyobjc-2.3.x/pyobjc-framework-Cocoa/Examples/AppKit/PyObjCLauncher/MyDocument.py (original)
+++ branches/pyobjc-2.3.x/pyobjc-framework-Cocoa/Examples/AppKit/PyObjCLauncher/MyDocument.py Tue Oct 12 12:24:14 2010
@@ -63,7 +63,7 @@
else:
res = os.system(cmdline)
if res:
- NSLog(u'Exit status: %d' % (res,))
+ NSLog(u'Exit status: %d', res)
return False
return True
Modified: branches/pyobjc-2.3.x/pyobjc-framework-Cocoa/Examples/AppKit/SimpleService/ServiceTest.py
==============================================================================
--- branches/pyobjc-2.3.x/pyobjc-framework-Cocoa/Examples/AppKit/SimpleService/ServiceTest.py (original)
+++ branches/pyobjc-2.3.x/pyobjc-framework-Cocoa/Examples/AppKit/SimpleService/ServiceTest.py Tue Oct 12 12:24:14 2010
@@ -8,14 +8,14 @@
return objc.selector(fn, signature="v@:@@o^@")
def ERROR(s):
- #NSLog(u"ERROR: %s" % (s,))
+ #NSLog(u"ERROR: %s", s)
return s
class ServiceTest(NSObject):
@serviceSelector
def doOpenFileService_userData_error_(self, pboard, data, error):
- #NSLog(u"doOpenFileService_userData_error_(%r, %r)" % (pboard, data,))
+ #NSLog(u"doOpenFileService_userData_error_(%s, %s)", pboard, data)
try:
types = pboard.types()
pboardString = None
@@ -42,7 +42,7 @@
@serviceSelector
def doCapitalizeService_userData_error_(self, pboard, data, err):
- #NSLog(u"doCapitalizeService_userData_error_(%r, %r)" % (pboard, data,))
+ #NSLog(u"doCapitalizeService_userData_error_(%s, %s)", pboard, data)
try:
types = pboard.types()
pboardString = None
Modified: branches/pyobjc-2.3.x/pyobjc-framework-Cocoa/Examples/AppKit/SimpleService/SimpleService_main.py
==============================================================================
--- branches/pyobjc-2.3.x/pyobjc-framework-Cocoa/Examples/AppKit/SimpleService/SimpleService_main.py (original)
+++ branches/pyobjc-2.3.x/pyobjc-framework-Cocoa/Examples/AppKit/SimpleService/SimpleService_main.py Tue Oct 12 12:24:14 2010
@@ -6,7 +6,7 @@
def main():
#NSLog(u"main()")
serviceProvider = ServiceTest.alloc().init()
- #NSLog(u"serviceProvider = %r" % (serviceProvider,))
+ #NSLog(u"serviceProvider = %s", serviceProvider)
NSRegisterServicesProvider(serviceProvider, u"PyObjCSimpleService")
#NSLog(u"registered as PyObjCSimpleService")
AppHelper.runConsoleEventLoop()
Modified: branches/pyobjc-2.3.x/pyobjc-framework-Cocoa/Examples/AppKit/TinyURLService/TinyURLService.py
==============================================================================
--- branches/pyobjc-2.3.x/pyobjc-framework-Cocoa/Examples/AppKit/TinyURLService/TinyURLService.py (original)
+++ branches/pyobjc-2.3.x/pyobjc-framework-Cocoa/Examples/AppKit/TinyURLService/TinyURLService.py Tue Oct 12 12:24:14 2010
@@ -11,7 +11,7 @@
return objc.selector(fn, signature="v@:@@o^@")
def ERROR(s):
- #NSLog(u"ERROR: %s" % (s,))
+ #NSLog(u"ERROR: %s", s)
return s
NAME = 'TinyURLService-0.0'
@@ -27,7 +27,7 @@
# Mail.app in 10.4.1 doesn't do NSURLPboardType correctly!
# Probably elsewhere too, so we just use strings.
try:
- #NSLog(u'doTinyURLService: %r' % (pboard,))
+ #NSLog(u'doTinyURLService: %s', pboard)
types = pboard.types()
url = None
@@ -35,10 +35,10 @@
if NSStringPboardType in types:
#NSLog(u'getting NSStringPboardType')
urlString = pboard.stringForType_(NSStringPboardType)
- #NSLog(u'NSStringPboardType: %r' % (urlString,))
+ #NSLog(u'NSStringPboardType: %s', urlString)
url = NSURL.URLWithString_(urlString.strip())
if url is None:
- #NSLog(u'urlString was %r' % (urlString,))
+ #NSLog(u'urlString was %s', urlString)
return ERROR(NSLocalizedString(
"Error: Given URL was not well-formed.",
"Given URL not well-formed."
@@ -52,15 +52,15 @@
urlString = url.absoluteString()
- #NSLog(u'urlString = %r' % (urlString,))
+ #NSLog(u'urlString = %s', urlString)
res = getTinyURL(urlString.UTF8String())
#NSLog(u'res = %r' % (res,))
resURL = NSURL.URLWithString_(res)
- #NSLog(u'resURL = %r' % (resURL,))
+ #NSLog(u'resURL = %s', resURL)
if resURL is None:
- NSLog(u'res was %r' % (res,))
+ NSLog(u'res was %s', res)
return ERROR(NSLocalizedString(
"Error: Resultant URL was not well-formed.",
"Resultant URL not well-formed."
Modified: branches/pyobjc-2.3.x/pyobjc-framework-ExceptionHandling/Lib/PyObjCTools/Debugging.py
==============================================================================
--- branches/pyobjc-2.3.x/pyobjc-framework-ExceptionHandling/Lib/PyObjCTools/Debugging.py (original)
+++ branches/pyobjc-2.3.x/pyobjc-framework-ExceptionHandling/Lib/PyObjCTools/Debugging.py Tue Oct 12 12:24:14 2010
@@ -56,7 +56,7 @@
pipe = os.popen('/usr/bin/atos -p %d %s' % (os.getpid(), stack))
stacktrace = pipe.readlines()
stacktrace.reverse()
- NSLog(u"*** ObjC exception '%s' (reason: '%s') discarded\n" % (
+ NSLog(u"%@", u"*** ObjC exception '%s' (reason: '%s') discarded\n" % (
exception.name(), exception.reason(),
) +
u'Stack trace (most recent call last):\n' +
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
Spend less time writing and rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb