PageRenderTime 55ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/IronPython_Main/Languages/IronPython/IronPython/Runtime/Exceptions/PythonExceptions.Generated.cs

#
C# | 1001 lines | 860 code | 120 blank | 21 comment | 151 complexity | 10c0ee6c760795b48bc27bf7ed98fdd5 MD5 | raw file
Possible License(s): GPL-2.0, MPL-2.0-no-copyleft-exception, CPL-1.0, CC-BY-SA-3.0, BSD-3-Clause, ISC, AGPL-3.0, LGPL-2.1, Apache-2.0
  1. /* ****************************************************************************
  2. *
  3. * Copyright (c) Microsoft Corporation.
  4. *
  5. * This source code is subject to terms and conditions of the Apache License, Version 2.0. A
  6. * copy of the license can be found in the License.html file at the root of this distribution. If
  7. * you cannot locate the Apache License, Version 2.0, please send an email to
  8. * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
  9. * by the terms of the Apache License, Version 2.0.
  10. *
  11. * You must not remove this notice, or any other, from this software.
  12. *
  13. *
  14. * ***************************************************************************/
  15. using System;
  16. using System.Collections.Generic;
  17. using System.ComponentModel;
  18. using System.IO;
  19. using System.Runtime.InteropServices;
  20. using System.Text;
  21. using Microsoft.Scripting;
  22. using Microsoft.Scripting.Runtime;
  23. using IronPython.Runtime.Operations;
  24. using IronPython.Runtime.Types;
  25. using Microsoft.Scripting.Utils;
  26. // This generated code is updated by the generate_exceptions.py script.
  27. namespace IronPython.Runtime.Exceptions {
  28. public static partial class PythonExceptions {
  29. private static object _pythonExceptionsLock = new object();
  30. #region Generated Python New-Style Exceptions
  31. // *** BEGIN GENERATED CODE ***
  32. // generated by function: newstyle_gen from: generate_exceptions.py
  33. [MultiRuntimeAware]
  34. private static PythonType GeneratorExitStorage;
  35. public static PythonType GeneratorExit {
  36. get {
  37. if (GeneratorExitStorage == null) {
  38. lock (_pythonExceptionsLock) {
  39. GeneratorExitStorage = CreateSubType(DynamicHelpers.GetPythonTypeFromType(typeof(BaseException)), "GeneratorExit", msg => new GeneratorExitException(msg));
  40. }
  41. }
  42. return GeneratorExitStorage;
  43. }
  44. }
  45. [MultiRuntimeAware]
  46. private static PythonType SystemExitStorage;
  47. public static PythonType SystemExit {
  48. get {
  49. if (SystemExitStorage == null) {
  50. lock (_pythonExceptionsLock) {
  51. SystemExitStorage = CreateSubType(DynamicHelpers.GetPythonTypeFromType(typeof(BaseException)), typeof(_SystemExit), msg => new SystemExitException(msg));
  52. }
  53. }
  54. return SystemExitStorage;
  55. }
  56. }
  57. [PythonType("SystemExit"), PythonHidden, DynamicBaseTypeAttribute, Serializable]
  58. public partial class _SystemExit : BaseException {
  59. private object _code;
  60. public _SystemExit() : base(SystemExit) { }
  61. public _SystemExit(PythonType type) : base(type) { }
  62. public new static object __new__(PythonType cls, params object[] args) {
  63. return Activator.CreateInstance(cls.UnderlyingSystemType, cls);
  64. }
  65. public object code {
  66. get { return _code; }
  67. set { _code = value; }
  68. }
  69. }
  70. [MultiRuntimeAware]
  71. private static PythonType KeyboardInterruptStorage;
  72. public static PythonType KeyboardInterrupt {
  73. get {
  74. if (KeyboardInterruptStorage == null) {
  75. lock (_pythonExceptionsLock) {
  76. KeyboardInterruptStorage = CreateSubType(DynamicHelpers.GetPythonTypeFromType(typeof(BaseException)), "KeyboardInterrupt", msg => new KeyboardInterruptException(msg));
  77. }
  78. }
  79. return KeyboardInterruptStorage;
  80. }
  81. }
  82. [MultiRuntimeAware]
  83. private static PythonType ExceptionStorage;
  84. public static PythonType Exception {
  85. get {
  86. if (ExceptionStorage == null) {
  87. lock (_pythonExceptionsLock) {
  88. ExceptionStorage = CreateSubType(DynamicHelpers.GetPythonTypeFromType(typeof(BaseException)), "Exception", msg => new PythonException(msg));
  89. }
  90. }
  91. return ExceptionStorage;
  92. }
  93. }
  94. [MultiRuntimeAware]
  95. private static PythonType StopIterationStorage;
  96. public static PythonType StopIteration {
  97. get {
  98. if (StopIterationStorage == null) {
  99. lock (_pythonExceptionsLock) {
  100. StopIterationStorage = CreateSubType(Exception, "StopIteration", msg => new StopIterationException(msg));
  101. }
  102. }
  103. return StopIterationStorage;
  104. }
  105. }
  106. [MultiRuntimeAware]
  107. private static PythonType StandardErrorStorage;
  108. public static PythonType StandardError {
  109. get {
  110. if (StandardErrorStorage == null) {
  111. lock (_pythonExceptionsLock) {
  112. StandardErrorStorage = CreateSubType(Exception, "StandardError", msg => new ApplicationException(msg));
  113. }
  114. }
  115. return StandardErrorStorage;
  116. }
  117. }
  118. [MultiRuntimeAware]
  119. private static PythonType BufferErrorStorage;
  120. public static PythonType BufferError {
  121. get {
  122. if (BufferErrorStorage == null) {
  123. lock (_pythonExceptionsLock) {
  124. BufferErrorStorage = CreateSubType(StandardError, "BufferError", msg => new BufferException(msg));
  125. }
  126. }
  127. return BufferErrorStorage;
  128. }
  129. }
  130. [MultiRuntimeAware]
  131. private static PythonType ArithmeticErrorStorage;
  132. public static PythonType ArithmeticError {
  133. get {
  134. if (ArithmeticErrorStorage == null) {
  135. lock (_pythonExceptionsLock) {
  136. ArithmeticErrorStorage = CreateSubType(StandardError, "ArithmeticError", msg => new ArithmeticException(msg));
  137. }
  138. }
  139. return ArithmeticErrorStorage;
  140. }
  141. }
  142. [MultiRuntimeAware]
  143. private static PythonType FloatingPointErrorStorage;
  144. public static PythonType FloatingPointError {
  145. get {
  146. if (FloatingPointErrorStorage == null) {
  147. lock (_pythonExceptionsLock) {
  148. FloatingPointErrorStorage = CreateSubType(ArithmeticError, "FloatingPointError", msg => new FloatingPointException(msg));
  149. }
  150. }
  151. return FloatingPointErrorStorage;
  152. }
  153. }
  154. [MultiRuntimeAware]
  155. private static PythonType OverflowErrorStorage;
  156. public static PythonType OverflowError {
  157. get {
  158. if (OverflowErrorStorage == null) {
  159. lock (_pythonExceptionsLock) {
  160. OverflowErrorStorage = CreateSubType(ArithmeticError, "OverflowError", msg => new OverflowException(msg));
  161. }
  162. }
  163. return OverflowErrorStorage;
  164. }
  165. }
  166. [MultiRuntimeAware]
  167. private static PythonType ZeroDivisionErrorStorage;
  168. public static PythonType ZeroDivisionError {
  169. get {
  170. if (ZeroDivisionErrorStorage == null) {
  171. lock (_pythonExceptionsLock) {
  172. ZeroDivisionErrorStorage = CreateSubType(ArithmeticError, "ZeroDivisionError", msg => new DivideByZeroException(msg));
  173. }
  174. }
  175. return ZeroDivisionErrorStorage;
  176. }
  177. }
  178. [MultiRuntimeAware]
  179. private static PythonType AssertionErrorStorage;
  180. public static PythonType AssertionError {
  181. get {
  182. if (AssertionErrorStorage == null) {
  183. lock (_pythonExceptionsLock) {
  184. AssertionErrorStorage = CreateSubType(StandardError, "AssertionError", msg => new AssertionException(msg));
  185. }
  186. }
  187. return AssertionErrorStorage;
  188. }
  189. }
  190. [MultiRuntimeAware]
  191. private static PythonType AttributeErrorStorage;
  192. public static PythonType AttributeError {
  193. get {
  194. if (AttributeErrorStorage == null) {
  195. lock (_pythonExceptionsLock) {
  196. AttributeErrorStorage = CreateSubType(StandardError, "AttributeError", msg => new AttributeErrorException(msg));
  197. }
  198. }
  199. return AttributeErrorStorage;
  200. }
  201. }
  202. [MultiRuntimeAware]
  203. private static PythonType EnvironmentErrorStorage;
  204. public static PythonType EnvironmentError {
  205. get {
  206. if (EnvironmentErrorStorage == null) {
  207. lock (_pythonExceptionsLock) {
  208. EnvironmentErrorStorage = CreateSubType(StandardError, typeof(_EnvironmentError), msg => new ExternalException(msg));
  209. }
  210. }
  211. return EnvironmentErrorStorage;
  212. }
  213. }
  214. [PythonType("EnvironmentError"), PythonHidden, DynamicBaseTypeAttribute, Serializable]
  215. public partial class _EnvironmentError : BaseException {
  216. private object _errno;
  217. private object _strerror;
  218. private object _filename;
  219. public _EnvironmentError() : base(EnvironmentError) { }
  220. public _EnvironmentError(PythonType type) : base(type) { }
  221. public new static object __new__(PythonType cls, params object[] args) {
  222. return Activator.CreateInstance(cls.UnderlyingSystemType, cls);
  223. }
  224. public object errno {
  225. get { return _errno; }
  226. set { _errno = value; }
  227. }
  228. public object strerror {
  229. get { return _strerror; }
  230. set { _strerror = value; }
  231. }
  232. public object filename {
  233. get { return _filename; }
  234. set { _filename = value; }
  235. }
  236. }
  237. [MultiRuntimeAware]
  238. private static PythonType IOErrorStorage;
  239. public static PythonType IOError {
  240. get {
  241. if (IOErrorStorage == null) {
  242. lock (_pythonExceptionsLock) {
  243. IOErrorStorage = CreateSubType(EnvironmentError, "IOError", msg => new IOException(msg));
  244. }
  245. }
  246. return IOErrorStorage;
  247. }
  248. }
  249. [MultiRuntimeAware]
  250. private static PythonType OSErrorStorage;
  251. public static PythonType OSError {
  252. get {
  253. if (OSErrorStorage == null) {
  254. lock (_pythonExceptionsLock) {
  255. OSErrorStorage = CreateSubType(EnvironmentError, "OSError", msg => new OSException(msg));
  256. }
  257. }
  258. return OSErrorStorage;
  259. }
  260. }
  261. [MultiRuntimeAware]
  262. private static PythonType WindowsErrorStorage;
  263. public static PythonType WindowsError {
  264. get {
  265. if (WindowsErrorStorage == null) {
  266. lock (_pythonExceptionsLock) {
  267. WindowsErrorStorage = CreateSubType(OSError, typeof(_WindowsError), msg => new Win32Exception(msg));
  268. }
  269. }
  270. return WindowsErrorStorage;
  271. }
  272. }
  273. [PythonType("WindowsError"), PythonHidden, DynamicBaseTypeAttribute, Serializable]
  274. public partial class _WindowsError : _EnvironmentError {
  275. private object _winerror;
  276. public _WindowsError() : base(WindowsError) { }
  277. public _WindowsError(PythonType type) : base(type) { }
  278. public new static object __new__(PythonType cls, params object[] args) {
  279. return Activator.CreateInstance(cls.UnderlyingSystemType, cls);
  280. }
  281. public object winerror {
  282. get { return _winerror; }
  283. set { _winerror = value; }
  284. }
  285. }
  286. [MultiRuntimeAware]
  287. private static PythonType EOFErrorStorage;
  288. public static PythonType EOFError {
  289. get {
  290. if (EOFErrorStorage == null) {
  291. lock (_pythonExceptionsLock) {
  292. EOFErrorStorage = CreateSubType(StandardError, "EOFError", msg => new EndOfStreamException(msg));
  293. }
  294. }
  295. return EOFErrorStorage;
  296. }
  297. }
  298. [MultiRuntimeAware]
  299. private static PythonType ImportErrorStorage;
  300. public static PythonType ImportError {
  301. get {
  302. if (ImportErrorStorage == null) {
  303. lock (_pythonExceptionsLock) {
  304. ImportErrorStorage = CreateSubType(StandardError, "ImportError", msg => new ImportException(msg));
  305. }
  306. }
  307. return ImportErrorStorage;
  308. }
  309. }
  310. [MultiRuntimeAware]
  311. private static PythonType LookupErrorStorage;
  312. public static PythonType LookupError {
  313. get {
  314. if (LookupErrorStorage == null) {
  315. lock (_pythonExceptionsLock) {
  316. LookupErrorStorage = CreateSubType(StandardError, "LookupError", msg => new LookupException(msg));
  317. }
  318. }
  319. return LookupErrorStorage;
  320. }
  321. }
  322. [MultiRuntimeAware]
  323. private static PythonType IndexErrorStorage;
  324. public static PythonType IndexError {
  325. get {
  326. if (IndexErrorStorage == null) {
  327. lock (_pythonExceptionsLock) {
  328. IndexErrorStorage = CreateSubType(LookupError, "IndexError", msg => new IndexOutOfRangeException(msg));
  329. }
  330. }
  331. return IndexErrorStorage;
  332. }
  333. }
  334. [MultiRuntimeAware]
  335. private static PythonType KeyErrorStorage;
  336. public static PythonType KeyError {
  337. get {
  338. if (KeyErrorStorage == null) {
  339. lock (_pythonExceptionsLock) {
  340. KeyErrorStorage = CreateSubType(LookupError, "KeyError", msg => new KeyNotFoundException(msg));
  341. }
  342. }
  343. return KeyErrorStorage;
  344. }
  345. }
  346. [MultiRuntimeAware]
  347. private static PythonType MemoryErrorStorage;
  348. public static PythonType MemoryError {
  349. get {
  350. if (MemoryErrorStorage == null) {
  351. lock (_pythonExceptionsLock) {
  352. MemoryErrorStorage = CreateSubType(StandardError, "MemoryError", msg => new OutOfMemoryException(msg));
  353. }
  354. }
  355. return MemoryErrorStorage;
  356. }
  357. }
  358. [MultiRuntimeAware]
  359. private static PythonType NameErrorStorage;
  360. public static PythonType NameError {
  361. get {
  362. if (NameErrorStorage == null) {
  363. lock (_pythonExceptionsLock) {
  364. NameErrorStorage = CreateSubType(StandardError, "NameError", msg => new UnboundNameException(msg));
  365. }
  366. }
  367. return NameErrorStorage;
  368. }
  369. }
  370. [MultiRuntimeAware]
  371. private static PythonType UnboundLocalErrorStorage;
  372. public static PythonType UnboundLocalError {
  373. get {
  374. if (UnboundLocalErrorStorage == null) {
  375. lock (_pythonExceptionsLock) {
  376. UnboundLocalErrorStorage = CreateSubType(NameError, "UnboundLocalError", msg => new UnboundLocalException(msg));
  377. }
  378. }
  379. return UnboundLocalErrorStorage;
  380. }
  381. }
  382. [MultiRuntimeAware]
  383. private static PythonType ReferenceErrorStorage;
  384. public static PythonType ReferenceError {
  385. get {
  386. if (ReferenceErrorStorage == null) {
  387. lock (_pythonExceptionsLock) {
  388. ReferenceErrorStorage = CreateSubType(StandardError, "ReferenceError", msg => new ReferenceException(msg));
  389. }
  390. }
  391. return ReferenceErrorStorage;
  392. }
  393. }
  394. [MultiRuntimeAware]
  395. private static PythonType RuntimeErrorStorage;
  396. public static PythonType RuntimeError {
  397. get {
  398. if (RuntimeErrorStorage == null) {
  399. lock (_pythonExceptionsLock) {
  400. RuntimeErrorStorage = CreateSubType(StandardError, "RuntimeError", msg => new RuntimeException(msg));
  401. }
  402. }
  403. return RuntimeErrorStorage;
  404. }
  405. }
  406. [MultiRuntimeAware]
  407. private static PythonType NotImplementedErrorStorage;
  408. public static PythonType NotImplementedError {
  409. get {
  410. if (NotImplementedErrorStorage == null) {
  411. lock (_pythonExceptionsLock) {
  412. NotImplementedErrorStorage = CreateSubType(RuntimeError, "NotImplementedError", msg => new NotImplementedException(msg));
  413. }
  414. }
  415. return NotImplementedErrorStorage;
  416. }
  417. }
  418. [MultiRuntimeAware]
  419. private static PythonType SyntaxErrorStorage;
  420. public static PythonType SyntaxError {
  421. get {
  422. if (SyntaxErrorStorage == null) {
  423. lock (_pythonExceptionsLock) {
  424. SyntaxErrorStorage = CreateSubType(StandardError, typeof(_SyntaxError), msg => new SyntaxErrorException(msg));
  425. }
  426. }
  427. return SyntaxErrorStorage;
  428. }
  429. }
  430. [PythonType("SyntaxError"), PythonHidden, DynamicBaseTypeAttribute, Serializable]
  431. public partial class _SyntaxError : BaseException {
  432. private object _text;
  433. private object _print_file_and_line;
  434. private object _filename;
  435. private object _lineno;
  436. private object _offset;
  437. private object _msg;
  438. public _SyntaxError() : base(SyntaxError) { }
  439. public _SyntaxError(PythonType type) : base(type) { }
  440. public new static object __new__(PythonType cls, params object[] args) {
  441. return Activator.CreateInstance(cls.UnderlyingSystemType, cls);
  442. }
  443. public object text {
  444. get { return _text; }
  445. set { _text = value; }
  446. }
  447. public object print_file_and_line {
  448. get { return _print_file_and_line; }
  449. set { _print_file_and_line = value; }
  450. }
  451. public object filename {
  452. get { return _filename; }
  453. set { _filename = value; }
  454. }
  455. public object lineno {
  456. get { return _lineno; }
  457. set { _lineno = value; }
  458. }
  459. public object offset {
  460. get { return _offset; }
  461. set { _offset = value; }
  462. }
  463. public object msg {
  464. get { return _msg; }
  465. set { _msg = value; }
  466. }
  467. }
  468. [MultiRuntimeAware]
  469. private static PythonType IndentationErrorStorage;
  470. public static PythonType IndentationError {
  471. get {
  472. if (IndentationErrorStorage == null) {
  473. lock (_pythonExceptionsLock) {
  474. IndentationErrorStorage = CreateSubType(SyntaxError, "IndentationError", msg => new IndentationException(msg));
  475. }
  476. }
  477. return IndentationErrorStorage;
  478. }
  479. }
  480. [MultiRuntimeAware]
  481. private static PythonType TabErrorStorage;
  482. public static PythonType TabError {
  483. get {
  484. if (TabErrorStorage == null) {
  485. lock (_pythonExceptionsLock) {
  486. TabErrorStorage = CreateSubType(IndentationError, "TabError", msg => new TabException(msg));
  487. }
  488. }
  489. return TabErrorStorage;
  490. }
  491. }
  492. [MultiRuntimeAware]
  493. private static PythonType SystemErrorStorage;
  494. public static PythonType SystemError {
  495. get {
  496. if (SystemErrorStorage == null) {
  497. lock (_pythonExceptionsLock) {
  498. SystemErrorStorage = CreateSubType(StandardError, "SystemError", msg => new SystemException(msg));
  499. }
  500. }
  501. return SystemErrorStorage;
  502. }
  503. }
  504. [MultiRuntimeAware]
  505. private static PythonType TypeErrorStorage;
  506. public static PythonType TypeError {
  507. get {
  508. if (TypeErrorStorage == null) {
  509. lock (_pythonExceptionsLock) {
  510. TypeErrorStorage = CreateSubType(StandardError, "TypeError", msg => new TypeErrorException(msg));
  511. }
  512. }
  513. return TypeErrorStorage;
  514. }
  515. }
  516. [MultiRuntimeAware]
  517. private static PythonType ValueErrorStorage;
  518. public static PythonType ValueError {
  519. get {
  520. if (ValueErrorStorage == null) {
  521. lock (_pythonExceptionsLock) {
  522. ValueErrorStorage = CreateSubType(StandardError, "ValueError", msg => new ValueErrorException(msg));
  523. }
  524. }
  525. return ValueErrorStorage;
  526. }
  527. }
  528. [MultiRuntimeAware]
  529. private static PythonType UnicodeErrorStorage;
  530. public static PythonType UnicodeError {
  531. get {
  532. if (UnicodeErrorStorage == null) {
  533. lock (_pythonExceptionsLock) {
  534. UnicodeErrorStorage = CreateSubType(ValueError, "UnicodeError", msg => new UnicodeException(msg));
  535. }
  536. }
  537. return UnicodeErrorStorage;
  538. }
  539. }
  540. [MultiRuntimeAware]
  541. private static PythonType UnicodeDecodeErrorStorage;
  542. public static PythonType UnicodeDecodeError {
  543. get {
  544. if (UnicodeDecodeErrorStorage == null) {
  545. lock (_pythonExceptionsLock) {
  546. UnicodeDecodeErrorStorage = CreateSubType(UnicodeError, typeof(_UnicodeDecodeError), msg => new DecoderFallbackException(msg));
  547. }
  548. }
  549. return UnicodeDecodeErrorStorage;
  550. }
  551. }
  552. [PythonType("UnicodeDecodeError"), PythonHidden, DynamicBaseTypeAttribute, Serializable]
  553. public partial class _UnicodeDecodeError : BaseException {
  554. private object _start;
  555. private object _reason;
  556. private object _object;
  557. private object _end;
  558. private object _encoding;
  559. public _UnicodeDecodeError() : base(UnicodeDecodeError) { }
  560. public _UnicodeDecodeError(PythonType type) : base(type) { }
  561. public new static object __new__(PythonType cls, params object[] args) {
  562. return Activator.CreateInstance(cls.UnderlyingSystemType, cls);
  563. }
  564. public void __init__(object encoding, object @object, object start, object end, object reason) {
  565. _encoding = encoding;
  566. _object = @object;
  567. _start = start;
  568. _end = end;
  569. _reason = reason;
  570. args = PythonTuple.MakeTuple(encoding, @object, start, end, reason);
  571. }
  572. public override void __init__(params object[] args) {
  573. if (args == null || args.Length != 5) {
  574. throw PythonOps.TypeError("__init__ takes exactly 5 arguments ({0} given)", args.Length);
  575. }
  576. __init__(encoding, @object, start, end, reason);
  577. }
  578. public object start {
  579. get { return _start; }
  580. set { _start = value; }
  581. }
  582. public object reason {
  583. get { return _reason; }
  584. set { _reason = value; }
  585. }
  586. public object @object {
  587. get { return _object; }
  588. set { _object = value; }
  589. }
  590. public object end {
  591. get { return _end; }
  592. set { _end = value; }
  593. }
  594. public object encoding {
  595. get { return _encoding; }
  596. set { _encoding = value; }
  597. }
  598. }
  599. [MultiRuntimeAware]
  600. private static PythonType UnicodeEncodeErrorStorage;
  601. public static PythonType UnicodeEncodeError {
  602. get {
  603. if (UnicodeEncodeErrorStorage == null) {
  604. lock (_pythonExceptionsLock) {
  605. UnicodeEncodeErrorStorage = CreateSubType(UnicodeError, typeof(_UnicodeEncodeError), msg => new EncoderFallbackException(msg));
  606. }
  607. }
  608. return UnicodeEncodeErrorStorage;
  609. }
  610. }
  611. [PythonType("UnicodeEncodeError"), PythonHidden, DynamicBaseTypeAttribute, Serializable]
  612. public partial class _UnicodeEncodeError : BaseException {
  613. private object _start;
  614. private object _reason;
  615. private object _object;
  616. private object _end;
  617. private object _encoding;
  618. public _UnicodeEncodeError() : base(UnicodeEncodeError) { }
  619. public _UnicodeEncodeError(PythonType type) : base(type) { }
  620. public new static object __new__(PythonType cls, params object[] args) {
  621. return Activator.CreateInstance(cls.UnderlyingSystemType, cls);
  622. }
  623. public void __init__(object encoding, object @object, object start, object end, object reason) {
  624. _encoding = encoding;
  625. _object = @object;
  626. _start = start;
  627. _end = end;
  628. _reason = reason;
  629. args = PythonTuple.MakeTuple(encoding, @object, start, end, reason);
  630. }
  631. public override void __init__(params object[] args) {
  632. if (args == null || args.Length != 5) {
  633. throw PythonOps.TypeError("__init__ takes exactly 5 arguments ({0} given)", args.Length);
  634. }
  635. __init__(encoding, @object, start, end, reason);
  636. }
  637. public object start {
  638. get { return _start; }
  639. set { _start = value; }
  640. }
  641. public object reason {
  642. get { return _reason; }
  643. set { _reason = value; }
  644. }
  645. public object @object {
  646. get { return _object; }
  647. set { _object = value; }
  648. }
  649. public object end {
  650. get { return _end; }
  651. set { _end = value; }
  652. }
  653. public object encoding {
  654. get { return _encoding; }
  655. set { _encoding = value; }
  656. }
  657. }
  658. [MultiRuntimeAware]
  659. private static PythonType UnicodeTranslateErrorStorage;
  660. public static PythonType UnicodeTranslateError {
  661. get {
  662. if (UnicodeTranslateErrorStorage == null) {
  663. lock (_pythonExceptionsLock) {
  664. UnicodeTranslateErrorStorage = CreateSubType(UnicodeError, typeof(_UnicodeTranslateError), msg => new UnicodeTranslateException(msg));
  665. }
  666. }
  667. return UnicodeTranslateErrorStorage;
  668. }
  669. }
  670. [PythonType("UnicodeTranslateError"), PythonHidden, DynamicBaseTypeAttribute, Serializable]
  671. public partial class _UnicodeTranslateError : BaseException {
  672. private object _start;
  673. private object _reason;
  674. private object _object;
  675. private object _end;
  676. private object _encoding;
  677. public _UnicodeTranslateError() : base(UnicodeTranslateError) { }
  678. public _UnicodeTranslateError(PythonType type) : base(type) { }
  679. public new static object __new__(PythonType cls, params object[] args) {
  680. return Activator.CreateInstance(cls.UnderlyingSystemType, cls);
  681. }
  682. public object start {
  683. get { return _start; }
  684. set { _start = value; }
  685. }
  686. public object reason {
  687. get { return _reason; }
  688. set { _reason = value; }
  689. }
  690. public object @object {
  691. get { return _object; }
  692. set { _object = value; }
  693. }
  694. public object end {
  695. get { return _end; }
  696. set { _end = value; }
  697. }
  698. public object encoding {
  699. get { return _encoding; }
  700. set { _encoding = value; }
  701. }
  702. }
  703. [MultiRuntimeAware]
  704. private static PythonType WarningStorage;
  705. public static PythonType Warning {
  706. get {
  707. if (WarningStorage == null) {
  708. lock (_pythonExceptionsLock) {
  709. WarningStorage = CreateSubType(Exception, "Warning", msg => new WarningException(msg));
  710. }
  711. }
  712. return WarningStorage;
  713. }
  714. }
  715. [MultiRuntimeAware]
  716. private static PythonType DeprecationWarningStorage;
  717. public static PythonType DeprecationWarning {
  718. get {
  719. if (DeprecationWarningStorage == null) {
  720. lock (_pythonExceptionsLock) {
  721. DeprecationWarningStorage = CreateSubType(Warning, "DeprecationWarning", msg => new DeprecationWarningException(msg));
  722. }
  723. }
  724. return DeprecationWarningStorage;
  725. }
  726. }
  727. [MultiRuntimeAware]
  728. private static PythonType PendingDeprecationWarningStorage;
  729. public static PythonType PendingDeprecationWarning {
  730. get {
  731. if (PendingDeprecationWarningStorage == null) {
  732. lock (_pythonExceptionsLock) {
  733. PendingDeprecationWarningStorage = CreateSubType(Warning, "PendingDeprecationWarning", msg => new PendingDeprecationWarningException(msg));
  734. }
  735. }
  736. return PendingDeprecationWarningStorage;
  737. }
  738. }
  739. [MultiRuntimeAware]
  740. private static PythonType RuntimeWarningStorage;
  741. public static PythonType RuntimeWarning {
  742. get {
  743. if (RuntimeWarningStorage == null) {
  744. lock (_pythonExceptionsLock) {
  745. RuntimeWarningStorage = CreateSubType(Warning, "RuntimeWarning", msg => new RuntimeWarningException(msg));
  746. }
  747. }
  748. return RuntimeWarningStorage;
  749. }
  750. }
  751. [MultiRuntimeAware]
  752. private static PythonType SyntaxWarningStorage;
  753. public static PythonType SyntaxWarning {
  754. get {
  755. if (SyntaxWarningStorage == null) {
  756. lock (_pythonExceptionsLock) {
  757. SyntaxWarningStorage = CreateSubType(Warning, "SyntaxWarning", msg => new SyntaxWarningException(msg));
  758. }
  759. }
  760. return SyntaxWarningStorage;
  761. }
  762. }
  763. [MultiRuntimeAware]
  764. private static PythonType UserWarningStorage;
  765. public static PythonType UserWarning {
  766. get {
  767. if (UserWarningStorage == null) {
  768. lock (_pythonExceptionsLock) {
  769. UserWarningStorage = CreateSubType(Warning, "UserWarning", msg => new UserWarningException(msg));
  770. }
  771. }
  772. return UserWarningStorage;
  773. }
  774. }
  775. [MultiRuntimeAware]
  776. private static PythonType FutureWarningStorage;
  777. public static PythonType FutureWarning {
  778. get {
  779. if (FutureWarningStorage == null) {
  780. lock (_pythonExceptionsLock) {
  781. FutureWarningStorage = CreateSubType(Warning, "FutureWarning", msg => new FutureWarningException(msg));
  782. }
  783. }
  784. return FutureWarningStorage;
  785. }
  786. }
  787. [MultiRuntimeAware]
  788. private static PythonType ImportWarningStorage;
  789. public static PythonType ImportWarning {
  790. get {
  791. if (ImportWarningStorage == null) {
  792. lock (_pythonExceptionsLock) {
  793. ImportWarningStorage = CreateSubType(Warning, "ImportWarning", msg => new ImportWarningException(msg));
  794. }
  795. }
  796. return ImportWarningStorage;
  797. }
  798. }
  799. [MultiRuntimeAware]
  800. private static PythonType UnicodeWarningStorage;
  801. public static PythonType UnicodeWarning {
  802. get {
  803. if (UnicodeWarningStorage == null) {
  804. lock (_pythonExceptionsLock) {
  805. UnicodeWarningStorage = CreateSubType(Warning, "UnicodeWarning", msg => new UnicodeWarningException(msg));
  806. }
  807. }
  808. return UnicodeWarningStorage;
  809. }
  810. }
  811. [MultiRuntimeAware]
  812. private static PythonType BytesWarningStorage;
  813. public static PythonType BytesWarning {
  814. get {
  815. if (BytesWarningStorage == null) {
  816. lock (_pythonExceptionsLock) {
  817. BytesWarningStorage = CreateSubType(Warning, "BytesWarning", msg => new BytesWarningException(msg));
  818. }
  819. }
  820. return BytesWarningStorage;
  821. }
  822. }
  823. // *** END GENERATED CODE ***
  824. #endregion
  825. #region Generated ToPython Exception Helper
  826. // *** BEGIN GENERATED CODE ***
  827. // generated by function: gen_topython_helper from: generate_exceptions.py
  828. private static BaseException/*!*/ ToPythonHelper(System.Exception clrException) {
  829. if (clrException is BytesWarningException) return new PythonExceptions.BaseException(PythonExceptions.BytesWarning);
  830. if (clrException is DecoderFallbackException) return new PythonExceptions._UnicodeDecodeError();
  831. if (clrException is DeprecationWarningException) return new PythonExceptions.BaseException(PythonExceptions.DeprecationWarning);
  832. if (clrException is DivideByZeroException) return new PythonExceptions.BaseException(PythonExceptions.ZeroDivisionError);
  833. if (clrException is EncoderFallbackException) return new PythonExceptions._UnicodeEncodeError();
  834. if (clrException is EndOfStreamException) return new PythonExceptions.BaseException(PythonExceptions.EOFError);
  835. if (clrException is FutureWarningException) return new PythonExceptions.BaseException(PythonExceptions.FutureWarning);
  836. if (clrException is ImportWarningException) return new PythonExceptions.BaseException(PythonExceptions.ImportWarning);
  837. if (clrException is MissingMemberException) return new PythonExceptions.BaseException(PythonExceptions.AttributeError);
  838. if (clrException is OverflowException) return new PythonExceptions.BaseException(PythonExceptions.OverflowError);
  839. if (clrException is PendingDeprecationWarningException) return new PythonExceptions.BaseException(PythonExceptions.PendingDeprecationWarning);
  840. if (clrException is RuntimeWarningException) return new PythonExceptions.BaseException(PythonExceptions.RuntimeWarning);
  841. if (clrException is SyntaxWarningException) return new PythonExceptions.BaseException(PythonExceptions.SyntaxWarning);
  842. if (clrException is TabException) return new PythonExceptions._SyntaxError(PythonExceptions.TabError);
  843. if (clrException is UnicodeWarningException) return new PythonExceptions.BaseException(PythonExceptions.UnicodeWarning);
  844. if (clrException is UserWarningException) return new PythonExceptions.BaseException(PythonExceptions.UserWarning);
  845. if (clrException is Win32Exception) return new PythonExceptions._WindowsError();
  846. if (clrException is ArgumentException) return new PythonExceptions.BaseException(PythonExceptions.ValueError);
  847. if (clrException is ArithmeticException) return new PythonExceptions.BaseException(PythonExceptions.ArithmeticError);
  848. if (clrException is ExternalException) return new PythonExceptions._EnvironmentError();
  849. if (clrException is IOException) return new PythonExceptions._EnvironmentError(PythonExceptions.IOError);
  850. if (clrException is IndentationException) return new PythonExceptions._SyntaxError(PythonExceptions.IndentationError);
  851. if (clrException is IndexOutOfRangeException) return new PythonExceptions.BaseException(PythonExceptions.IndexError);
  852. if (clrException is KeyNotFoundException) return new PythonExceptions.BaseException(PythonExceptions.KeyError);
  853. if (clrException is NotImplementedException) return new PythonExceptions.BaseException(PythonExceptions.NotImplementedError);
  854. if (clrException is OSException) return new PythonExceptions._EnvironmentError(PythonExceptions.OSError);
  855. if (clrException is OutOfMemoryException) return new PythonExceptions.BaseException(PythonExceptions.MemoryError);
  856. if (clrException is UnboundLocalException) return new PythonExceptions.BaseException(PythonExceptions.UnboundLocalError);
  857. if (clrException is UnicodeTranslateException) return new PythonExceptions._UnicodeTranslateError();
  858. if (clrException is WarningException) return new PythonExceptions.BaseException(PythonExceptions.Warning);
  859. if (clrException is ApplicationException) return new PythonExceptions.BaseException(PythonExceptions.StandardError);
  860. if (clrException is ArgumentTypeException) return new PythonExceptions.BaseException(PythonExceptions.TypeError);
  861. if (clrException is AssertionException) return new PythonExceptions.BaseException(PythonExceptions.AssertionError);
  862. if (clrException is BufferException) return new PythonExceptions.BaseException(PythonExceptions.BufferError);
  863. if (clrException is FloatingPointException) return new PythonExceptions.BaseException(PythonExceptions.FloatingPointError);
  864. if (clrException is GeneratorExitException) return new PythonExceptions.BaseException(PythonExceptions.GeneratorExit);
  865. if (clrException is ImportException) return new PythonExceptions.BaseException(PythonExceptions.ImportError);
  866. if (clrException is KeyboardInterruptException) return new PythonExceptions.BaseException(PythonExceptions.KeyboardInterrupt);
  867. if (clrException is LookupException) return new PythonExceptions.BaseException(PythonExceptions.LookupError);
  868. if (clrException is PythonException) return new PythonExceptions.BaseException(PythonExceptions.Exception);
  869. if (clrException is ReferenceException) return new PythonExceptions.BaseException(PythonExceptions.ReferenceError);
  870. if (clrException is RuntimeException) return new PythonExceptions.BaseException(PythonExceptions.RuntimeError);
  871. if (clrException is StopIterationException) return new PythonExceptions.BaseException(PythonExceptions.StopIteration);
  872. if (clrException is SyntaxErrorException) return new PythonExceptions._SyntaxError();
  873. if (clrException is SystemException) return new PythonExceptions.BaseException(PythonExceptions.SystemError);
  874. if (clrException is SystemExitException) return new PythonExceptions._SystemExit();
  875. if (clrException is UnboundNameException) return new PythonExceptions.BaseException(PythonExceptions.NameError);
  876. return new BaseException(Exception);
  877. }
  878. // *** END GENERATED CODE ***
  879. #endregion
  880. }
  881. }