mirror of
				https://github.com/Mikaela/Limnoria.git
				synced 2025-10-31 07:37:22 +01:00 
			
		
		
		
	Fix for a few exceptions escaping, bug #826177 in partciular.
This commit is contained in:
		
							parent
							
								
									37b796ac74
								
							
						
					
					
						commit
						487ac95d80
					
				| @ -152,6 +152,8 @@ class Math(callbacks.Privmsg): | ||||
|             irc.error(msg, 'Go get scanez, this is a *real* math problem!') | ||||
|         except TypeError: | ||||
|             irc.error(msg, 'Something in there wasn\'t a valid number.') | ||||
|         except NameError, e: | ||||
|             irc.error(msg, '%s is not a defined function.' % str(e).split()[1]) | ||||
|         except Exception, e: | ||||
|             irc.error(msg, debug.exnToString(e)) | ||||
| 
 | ||||
| @ -194,7 +196,11 @@ class Math(callbacks.Privmsg): | ||||
|                     arg2 = stack.pop() | ||||
|                     arg1 = stack.pop() | ||||
|                     s = '%s%s%s' % (arg1, arg, arg2) | ||||
|                     stack.append(eval(s, self._mathEnv, self._mathEnv)) | ||||
|                     try: | ||||
|                         stack.append(eval(s, self._mathEnv, self._mathEnv)) | ||||
|                     except SyntaxError: | ||||
|                         irc.error(msg, '%r is not a defined function.' % arg) | ||||
|                         return | ||||
|         if len(stack) == 1: | ||||
|             irc.reply(msg, str(self._complexToString(complex(stack[0])))) | ||||
|         else: | ||||
|  | ||||
| @ -47,12 +47,18 @@ class MathTestCase(PluginTestCase, PluginDocumentation): | ||||
| ##         self.assertNotError('calc log(8,2)') | ||||
| ##         self.assertNotError('calc log(8,2)') | ||||
| 
 | ||||
|     def testCalcNoNameError(self): | ||||
|         self.assertNotRegexp('calc foobar(x)', 'NameError') | ||||
|          | ||||
|     def testRpn(self): | ||||
|         self.assertResponse('rpn 5 2 +', '7') | ||||
|         self.assertResponse('rpn 1 2 3 +', 'Stack: [1, 5]') | ||||
|         self.assertResponse('rpn 1 dup', 'Stack: [1, 1]') | ||||
|         self.assertResponse('rpn 2 3 4 + -', str(2-7)) | ||||
|         self.assertNotError('rpn 2 degrees') | ||||
| 
 | ||||
|     def testRpmNoSyntaxError(self): | ||||
|         self.assertNotRegexp('rpn 2 3 foobar', 'SyntaxError') | ||||
|          | ||||
|     def testConvert(self): | ||||
|         self.assertResponse('convert 1 m to cm', '100.0 cm') | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Jeremy Fincher
						Jeremy Fincher