Skip to main content

A Debugger-Cooperative Higher-Order Contract System in Python

  • Conference paper
  • First Online:
Programming Languages and Systems (APLAS 2016)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 10017))

Included in the following conference series:

Abstract

Contract programming is one of the most promising ways of enhancing the reliability of Python, which becomes increasingly desired. Higher-order contract systems that support fully specifying the behaviors of iterators and functions are desirable for Python but have not been presented yet. Besides, even with them, debugging with contracts in Python would still be burdensome because of delayed contract checking. To resolve this problem, we present PyBlame, a higher-order contract system in Python, and ccdb, a source-level debugger equipped with features dedicated to debugging with delayed contract checking. PyBlame and ccdb are designed on the basis of the standard of Python and thus friendly to many Python programmers. We have experimentally confirmed the advantage and the efficacy of PyBlame and ccdb through the web framework Bottle.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    https://github.com/AndreaCensi/contracts.

  2. 2.

    http://www.numpy.org/.

  3. 3.

    http://www.tornadoweb.org/.

  4. 4.

    http://bottlepy.org/.

  5. 5.

    http://flask.pocoo.org/.

  6. 6.

    https://racket-lang.org/.

  7. 7.

    http://docs.python.org/3/.

  8. 8.

    https://docs.racket-lang.org/reference/data-structure-contracts.html.

  9. 9.

    https://docs.python.org/3/library/index.html.

  10. 10.

    https://github.com/mvitousek/reticulated.

  11. 11.

    http://doc.pypy.org/en/latest/objspace-proxies.html.

  12. 12.

    https://docs.racket-lang.org/reference/contracts.html.

  13. 13.

    https://www.typescriptlang.org/.

  14. 14.

    http://hacklang.org/.

  15. 15.

    https://docs.racket-lang.org/ts-guide/.

  16. 16.

    http://mypy-lang.org/.

References

  1. D12.1: High-level backends and interpreter feature prototypes. PyPy EU-Report (2007)

    Google Scholar 

  2. Carrillo-Castellon, M., Garcia-Molina, J., Pimentel, E., Repiso, I.: Design by contract in smalltalk. J. Object-Oriented Program 7(9), 23–28 (1996)

    Google Scholar 

  3. Chiş, A., Gîrba, T., Nierstrasz, O.: The moldable debugger: a framework for developing domain-specific debuggers. In: Proceedings of the 2015 ACM SIGPLAN International Conference on Software Language Engineering, SLE 2014, pp. 102–121. ACM (2014)

    Google Scholar 

  4. Chitil, O.: Practical typed lazy contracts. In: Proceedings of the 17th ACM SIGPLAN International Conference on Functional Programming, ICFP 2012, pp. 67–76. ACM (2012)

    Google Scholar 

  5. Chugh, R., Herman, D., Jhala, R.: Dependent types for JavaScript. In: Proceedings of the 2012 ACM International Conference on Object Oriented Programming Systems Languages and Applications, OOPSLA 2012, pp. 587–606. ACM (2012)

    Google Scholar 

  6. Chugh, R., Rondon, P.M., Jhala, R.: Nested refinements: a logic for duck typing. In: Proceedings of the 39th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2012, pp. 231–244. ACM (2012)

    Google Scholar 

  7. Dimoulas, C., Findler, R.B., Felleisen, M.: Option contracts. In: Proceedings of the 2013 ACM SIGPLAN International Conference on Object Oriented Programming Systems Languages and Applications, OOPSLA 2013, pp. 475–494. ACM (2013)

    Google Scholar 

  8. Eby, P.J.: PEP 3333 - Python Web Server Gateway Interface v1.0.1 (2010). https://www.python.org/dev/peps/pep-3333/

  9. Fähndrich, M., Barnett, M., Leijen, D., Logozzo, F.: Integrating a set of contract checking tools into visual studio. In: Proceedings of the Second International Workshop on Developing Tools as Plug-Ins, TOPI 2012, pp. 43–48. IEEE (2012)

    Google Scholar 

  10. Findler, R.B., Felleisen, M.: Contracts for higher-order functions. In: Proceedings of the Seventh ACM SIGPLAN International Conference on Functional Programming, ICFP 2002, pp. 48–59. ACM (2002)

    Google Scholar 

  11. Flanagan, C.: Hybrid type checking. In: Conference Record of the 33rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2006, pp. 245–256. ACM (2006)

    Google Scholar 

  12. Heidegger, P., Bieniusa, A., Thiemann, P.: Access permission contracts for scripting languages. In: Proceedings of the 39th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2012, pp. 111–122. ACM (2012)

    Google Scholar 

  13. Heidegger, P., Thiemann, P.: Contract-driven testing of JavaScript code. In: Vitek, J. (ed.) TOOLS 2010. LNCS, vol. 6141, pp. 154–172. Springer, Heidelberg (2010). doi:10.1007/978-3-642-13953-6_9

    Chapter  Google Scholar 

  14. Keil, M., Thiemann, P.: Blame assignment for higher-order contracts with intersection and union. In: Proceedings of the 20th ACM SIGPLAN International Conference on Functional Programming, ICFP 2015, pp. 375–386. ACM (2015)

    Google Scholar 

  15. Klein, C., Flatt, M., Findler, R.B.: Random testing for higher-order, stateful programs. In: Proceedings of the 2010 ACM International Conference on Object Oriented Programming Systems Languages and Applications, OOPSLA 2010, pp. 555–566. ACM (2010)

    Google Scholar 

  16. Knowles, K., Flanagan, C.: Hybrid type checking. ACM Trans. Program. Lang. Syst. 32(2), 6:1–6:34 (2010)

    Article  Google Scholar 

  17. Meyer, B.: Applying “Design by Contract”. Computer 25(10), 40–51 (1992)

    Article  Google Scholar 

  18. Plösch, R.: Design by contract for Python. In: Proceedings of the Fourth Asia-Pacific Software Engineering and International Computer Science Conference, APSEC 1997, pp. 213–219. IEEE (1997)

    Google Scholar 

  19. van Rossum, G., Lehtosalo, J., Langa, Ł.: PEP 484 - Type Hints (2014). https://www.python.org/dev/peps/pep-0484/

  20. Siek, J.G., Taha, W.: Gradual typing for functional languages. In: Scheme and Functional Programming 2006. TR-2006-06, University of Chicago (2006)

    Google Scholar 

  21. Strickland, T.S., Dimoulas, C., Takikawa, A., Felleisen, M.: Contracts for first-class classes. ACM Trans. Program. Lang. Syst. 35(3), 11:1–11:58 (2013)

    Article  Google Scholar 

  22. Strickland, T.S., Felleisen, M.: Contracts for first-class classes. In: Proceedings of the 6th Symposium on Dynamic Languages, DLS 2010, pp. 97–112. ACM (2010)

    Google Scholar 

  23. Strickland, T.S., Tobin-Hochstadt, S., Findler, R.B., Flatt, M.: Chaperones and impersonators: run-time support for reasonable interposition. In: Proceedings of the 2012 ACM International Conference on Object Oriented Programming Systems Languages and Applications, OOPSLA 2012, pp. 943–962. ACM (2012)

    Google Scholar 

  24. Vitousek, M.M., Kent, A.M., Siek, J.G., Baker, J.: Design and evaluation of gradual typing for Python. In: Proceedings of the 10th ACM Symposium on Dynamic Languages, DLS 2014, pp. 45–56. ACM (2014)

    Google Scholar 

  25. Wei, Y., Pei, Y., Furia, C.A., Silva, L.S., Buchholz, S., Meyer, B., Zeller, A.: Automated fixing of programs with contracts. In: Proceedings of the 19th International Symposium on Software Testing and Analysis, ISSTA 2010, pp. 61–72. ACM (2010)

    Google Scholar 

  26. Zhang, C., Yan, D., Zhao, J., Chen, Y., Yang, S.: BPGen: an automated breakpoint generator for debugging. In: Proceedings of the 32nd ACM/IEEE International Conference on Software Engineering, ICSE 2010, vol. 2, pp. 271–274. ACM (2010)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Shigeyuki Sato .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2016 Springer International Publishing AG

About this paper

Cite this paper

Arai, R., Sato, S., Iwasaki, H. (2016). A Debugger-Cooperative Higher-Order Contract System in Python. In: Igarashi, A. (eds) Programming Languages and Systems. APLAS 2016. Lecture Notes in Computer Science(), vol 10017. Springer, Cham. https://doi.org/10.1007/978-3-319-47958-3_9

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-47958-3_9

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-47957-6

  • Online ISBN: 978-3-319-47958-3

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics