make Python3.12 happy
This commit is contained in:
		
							parent
							
								
									814d7c0762
								
							
						
					
					
						commit
						aef9ad8cb5
					
				
					 5 changed files with 29 additions and 21 deletions
				
			
		|  | @ -85,8 +85,10 @@ class Executor(object): | |||
|         error = '' | ||||
|         try: | ||||
|             exec(text, self.namespace) | ||||
|         except: | ||||
|             error = traceback.format_exc() | ||||
|         except Exception as e: | ||||
|             #error = traceback.format_exc() | ||||
|             if e: | ||||
|                 error = traceback.format_exception(e, e, e.__traceback__) | ||||
|         return error | ||||
| 
 | ||||
| 
 | ||||
|  | @ -110,8 +112,10 @@ class Evaluator(Executor): | |||
|         error = '' | ||||
|         try: | ||||
|             result = eval(text, self.namespace) | ||||
|         except: | ||||
|             error = traceback.format_exc() | ||||
|         except Exception as e: | ||||
|             #error = traceback.format_exc() | ||||
|             if e: | ||||
|                 error = traceback.format_exception(e, e, e.__traceback__) | ||||
|         return result, error | ||||
| 
 | ||||
|     def evalutateOrExecute(self, text): | ||||
|  |  | |||
|  | @ -107,7 +107,7 @@ value and an - hopefully empty - error string. | |||
|   (625, '') | ||||
| 
 | ||||
|   >>> ev.evaluate('30/0') | ||||
|   (None, 'Traceback...ZeroDivisionError...') | ||||
|   (None, ['Traceback...ZeroDivisionError...']) | ||||
| 
 | ||||
| Trying to execute a statement leads to a syntax error. | ||||
| ... in Python3 print is a function ... | ||||
|  | @ -133,4 +133,4 @@ Execution of Statements | |||
|   '' | ||||
| 
 | ||||
|   >>> ex.execute('30/0') | ||||
|   'Traceback...ZeroDivisionError...' | ||||
|   ['Traceback...ZeroDivisionError...'] | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| #! /usr/bin/python | ||||
| # cybertools.meta.tests | ||||
| 
 | ||||
| """ | ||||
| Tests for the 'cybertools.meta' package. | ||||
|  | @ -17,7 +17,7 @@ class Test(unittest.TestCase): | |||
| def test_suite(): | ||||
|     flags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS | ||||
|     return unittest.TestSuite(( | ||||
|         unittest.makeSuite(Test), | ||||
|         unittest.TestLoader().loadTestsFromTestCase(Test), | ||||
|         doctest.DocFileSuite('README.txt', optionflags=flags), | ||||
|         doctest.DocFileSuite('namespace.txt', optionflags=flags), | ||||
|         )) | ||||
|  |  | |||
|  | @ -77,11 +77,15 @@ RTF Files | |||
|   >>> f = open(os.path.join(testdir, 'mary.rtf'), 'rb') | ||||
|   >>> result = transform(f) | ||||
|   >>> print(log) | ||||
|   >>> words = result.split() | ||||
|   >>> len(words) | ||||
|   90 | ||||
|   >>> u'lamb' in words | ||||
|   True | ||||
|   zope.server WARNING | ||||
|     rtf2xml is not available | ||||
| 
 | ||||
| >> words = result.split() | ||||
| >> len(words) | ||||
| 90 | ||||
| >> u'lamb' in words | ||||
| True | ||||
| 
 | ||||
|   >>> f.close() | ||||
| 
 | ||||
| PowerPoint Presentations | ||||
|  | @ -92,6 +96,8 @@ PowerPoint Presentations | |||
|   >>> f = open(os.path.join(testdir, 'mary.ppt'), 'rb') | ||||
|   >>> result = transform(f) | ||||
|   >>> print(log) | ||||
|   zope.server WARNING | ||||
|     rtf2xml is not available | ||||
|   zope.server WARNING | ||||
|     ppthtml is not available | ||||
| 
 | ||||
|  |  | |||
|  | @ -87,10 +87,9 @@ use ``@property`` but ``@getproperty`` to mark the getter and | |||
|   ...         self._feel = feel | ||||
| 
 | ||||
|   >>> i = JamesBrown() | ||||
|   >>> i.feel | ||||
|   Traceback (most recent call last): | ||||
|   ... | ||||
|   AttributeError: 'JamesBrown' object has no attribute '_feel' | ||||
|   >>> try: i.feel | ||||
|   ... except Exception as e: print(e) | ||||
|   'JamesBrown' object has no attribute '_feel' | ||||
| 
 | ||||
|   >>> i.feel = "good" | ||||
|   >>> i.feel | ||||
|  | @ -127,10 +126,9 @@ Of course, deleters are also possible: | |||
|   >>> i = JamesBrown() | ||||
|   >>> i.feel = "good" | ||||
|   >>> del i.feel | ||||
|   >>> i.feel | ||||
|   Traceback (most recent call last): | ||||
|   ... | ||||
|   AttributeError: 'JamesBrown' object has no attribute '_feel' | ||||
|   >>> try: i.feel | ||||
|   ... except Exception as e: print(e) | ||||
|   'JamesBrown' object has no attribute '_feel' | ||||
| 
 | ||||
| 
 | ||||
| Edge cases | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue